svn commit: samba r4012 - in branches/SAMBA_4_0/source/rpc_server/lsa: .

tridge at samba.org tridge at samba.org
Tue Nov 30 04:34:18 GMT 2004


Author: tridge
Date: 2004-11-30 04:34:18 +0000 (Tue, 30 Nov 2004)
New Revision: 4012

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4012

Log:
split out the lsa lookup single name logic into a separate function

Modified:
   branches/SAMBA_4_0/source/rpc_server/lsa/dcesrv_lsa.c


Changeset:
Modified: branches/SAMBA_4_0/source/rpc_server/lsa/dcesrv_lsa.c
===================================================================
--- branches/SAMBA_4_0/source/rpc_server/lsa/dcesrv_lsa.c	2004-11-30 04:33:27 UTC (rev 4011)
+++ branches/SAMBA_4_0/source/rpc_server/lsa/dcesrv_lsa.c	2004-11-30 04:34:18 UTC (rev 4012)
@@ -1025,6 +1025,38 @@
 }
 
 /*
+  lookup a SID for 1 name
+*/
+static NTSTATUS lsa_lookup_name(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
+				const char *name, struct dom_sid **sid, uint32_t *atype)
+{
+	int ret;
+	struct ldb_message **res;
+	const char * const attrs[] = { "objectSid", "sAMAccountType", NULL};
+
+	ret = samdb_search(state->sam_ctx, mem_ctx, NULL, &res, attrs, "sAMAccountName=%s", name);
+	if (ret == 1) {
+		const char *sid_str = ldb_msg_find_string(res[0], "objectSid", NULL);
+		if (sid_str == NULL) {
+			return NT_STATUS_INVALID_SID;
+		}
+
+		*sid = dom_sid_parse_talloc(mem_ctx, sid_str);
+		if (*sid == NULL) {
+			return NT_STATUS_INVALID_SID;
+		}
+
+		*atype = samdb_result_uint(res[0], "sAMAccountType", 0);
+
+		return NT_STATUS_OK;
+	}
+
+	/* need to add a call into sidmap to check for a allocated sid */
+
+	return NT_STATUS_INVALID_SID;
+}
+
+/*
   lsa_LookupNames2
 */
 static NTSTATUS lsa_LookupNames2(struct dcesrv_call_state *dce_call,
@@ -1061,11 +1093,7 @@
 	}
 
 	for (i=0;i<r->in.num_names;i++) {
-		const char * const attrs[] = { "objectSid", "sAMAccountType", NULL};
 		const char *name = r->in.names[i].string;
-		int ret;
-		const char *sid_str;
-		struct ldb_message **res;
 		struct dom_sid *sid;
 		uint32_t atype, rtype, sid_index;
 		NTSTATUS status2;
@@ -1078,30 +1106,12 @@
 		r->out.sids->sids[i].sid_index   = 0xFFFFFFFF;
 		r->out.sids->sids[i].unknown     = 0;
 
-		ret = samdb_search(state->sam_ctx, mem_ctx, NULL, &res, attrs, "sAMAccountName=%s", name);
-		if (ret != 1) {
+		status2 = lsa_lookup_name(state, mem_ctx, name, &sid, &atype);
+		if (!NT_STATUS_IS_OK(status) || sid->num_auths == 0) {
 			status = STATUS_SOME_UNMAPPED;
 			continue;
 		}
 
-		sid_str = ldb_msg_find_string(res[0], "objectSid", NULL);
-		if (sid_str == NULL) {
-			status = STATUS_SOME_UNMAPPED;
-			continue;
-		}
-
-		sid = dom_sid_parse_talloc(mem_ctx, sid_str);
-		if (sid == NULL || sid->num_auths == 0) {
-			status = STATUS_SOME_UNMAPPED;
-			continue;
-		}
-
-		atype = samdb_result_uint(res[0], "sAMAccountType", 0);
-		if (atype == 0) {
-			status = STATUS_SOME_UNMAPPED;
-			continue;
-		}
-
 		rtype = samdb_atype_map(atype);
 		if (rtype == SID_NAME_UNKNOWN) {
 			status = STATUS_SOME_UNMAPPED;



More information about the samba-cvs mailing list