summaryrefslogtreecommitdiff
path: root/source4/rpc_server
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-05-09 12:32:25 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:51:51 -0500
commita765d3692fd6583ca98fea7907af4aa934dfc68c (patch)
tree2156304ce022d1af8ffb75e8493fe15cb8f7d858 /source4/rpc_server
parent5dc73338d22ce95299ed62b73d1c15c94581495e (diff)
downloadsamba-a765d3692fd6583ca98fea7907af4aa934dfc68c.tar.gz
samba-a765d3692fd6583ca98fea7907af4aa934dfc68c.tar.bz2
samba-a765d3692fd6583ca98fea7907af4aa934dfc68c.zip
r608: - a couple of very minor fixes to the CreateGroup code
- added samr_GetUserPwInfo() samr server call (This used to be commit 0250f5d6aaf4f9325ace707c69f5e24bcd7a0ed9)
Diffstat (limited to 'source4/rpc_server')
-rw-r--r--source4/rpc_server/samr/dcesrv_samr.c26
-rw-r--r--source4/rpc_server/samr/samdb.c34
2 files changed, 49 insertions, 11 deletions
diff --git a/source4/rpc_server/samr/dcesrv_samr.c b/source4/rpc_server/samr/dcesrv_samr.c
index b14d807d35..6eae4bc2bb 100644
--- a/source4/rpc_server/samr/dcesrv_samr.c
+++ b/source4/rpc_server/samr/dcesrv_samr.c
@@ -445,7 +445,7 @@ static void samr_Account_destroy(struct dcesrv_connection *conn, struct dcesrv_h
samr_CreateDomainGroup
*/
static NTSTATUS samr_CreateDomainGroup(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct samr_CreateDomainGroup *r)
+ struct samr_CreateDomainGroup *r)
{
struct samr_domain_state *d_state;
struct samr_account_state *state;
@@ -475,7 +475,7 @@ static NTSTATUS samr_CreateDomainGroup(struct dcesrv_call_state *dce_call, TALLO
/* check if the group already exists */
name = samdb_search_string(d_state->sam_ctx, mem_ctx, d_state->basedn,
- "name",
+ "sAMAccountName",
"(&(sAMAccountName=%s)(objectclass=group))",
groupname);
if (name != NULL) {
@@ -533,7 +533,7 @@ static NTSTATUS samr_CreateDomainGroup(struct dcesrv_call_state *dce_call, TALLO
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
- /* create user state and new policy handle */
+ /* create group state and new policy handle */
mem_ctx2 = talloc_init("CreateDomainGroup(%s)", groupname);
if (!mem_ctx2) {
return NT_STATUS_NO_MEMORY;
@@ -620,7 +620,8 @@ static NTSTATUS samr_CreateUser2(struct dcesrv_call_state *dce_call, TALLOC_CTX
/* check if the user already exists */
name = samdb_search_string(d_state->sam_ctx, mem_ctx, d_state->basedn,
- "name", "(&(sAMAccountName=%s)(objectclass=user))", username);
+ "sAMAccountName",
+ "(&(sAMAccountName=%s)(objectclass=user))", username);
if (name != NULL) {
return NT_STATUS_USER_EXISTS;
}
@@ -1611,9 +1612,22 @@ static NTSTATUS samr_TestPrivateFunctionsUser(struct dcesrv_call_state *dce_call
samr_GetUserPwInfo
*/
static NTSTATUS samr_GetUserPwInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct samr_GetUserPwInfo *r)
+ struct samr_GetUserPwInfo *r)
{
- DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+ struct dcesrv_handle *h;
+ struct samr_account_state *state;
+
+ ZERO_STRUCT(r->out.info);
+
+ DCESRV_PULL_HANDLE(h, r->in.handle, SAMR_HANDLE_USER);
+
+ state = h->data;
+
+ r->out.info.min_pwd_len = samdb_search_uint(state->sam_ctx, mem_ctx, 0, NULL, "minPwdLength",
+ "dn=%s", state->domain_state->basedn);
+ r->out.info.password_properties = samdb_search_uint(state->sam_ctx, mem_ctx, 0, NULL, "pwdProperties",
+ "dn=%s", state->basedn);
+ return NT_STATUS_OK;
}
diff --git a/source4/rpc_server/samr/samdb.c b/source4/rpc_server/samr/samdb.c
index af915e599f..c6a85176da 100644
--- a/source4/rpc_server/samr/samdb.c
+++ b/source4/rpc_server/samr/samdb.c
@@ -205,6 +205,33 @@ const char *samdb_search_string(void *ctx,
return str;
}
+
+/*
+ search the sam for a single integer attribute in exactly 1 record
+*/
+uint_t samdb_search_uint(void *ctx,
+ TALLOC_CTX *mem_ctx,
+ uint_t default_value,
+ const char *basedn,
+ const char *attr_name,
+ const char *format, ...)
+{
+ va_list ap;
+ int count;
+ struct ldb_message **res;
+ const char * const attrs[2] = { attr_name, NULL };
+
+ va_start(ap, format);
+ count = samdb_search_v(ctx, mem_ctx, basedn, &res, attrs, format, ap);
+ va_end(ap);
+
+ if (count != 1) {
+ return default_value;
+ }
+
+ return samdb_result_uint(res[0], attr_name, default_value);
+}
+
/*
search the sam for multipe records each giving a single string attribute
return the number of matches, or -1 on error
@@ -426,11 +453,8 @@ int samdb_copy_template(void *ctx, TALLOC_CTX *mem_ctx,
}
for (j=0;j<el->num_values;j++) {
if (strcasecmp(el->name, "objectClass") == 0 &&
- strcasecmp((char *)el->values[j].data, "userTemplate") == 0) {
- continue;
- }
- if (strcasecmp(el->name, "objectClass") == 0 &&
- strcasecmp((char *)el->values[j].data, "groupTemplate") == 0) {
+ (strcasecmp((char *)el->values[j].data, "userTemplate") == 0 ||
+ strcasecmp((char *)el->values[j].data, "groupTemplate") == 0)) {
continue;
}
samdb_msg_add_string(ctx, mem_ctx, msg, el->name,