svn commit: samba r4372 - in branches/SAMBA_4_0/source/rpc_server/samr: .

vlendec at samba.org vlendec at samba.org
Sun Dec 26 23:31:20 GMT 2004


Author: vlendec
Date: 2004-12-26 23:31:19 +0000 (Sun, 26 Dec 2004)
New Revision: 4372

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

Log:
Implement samr_LookupRids
Modified:
   branches/SAMBA_4_0/source/rpc_server/samr/dcesrv_samr.c


Changeset:
Modified: branches/SAMBA_4_0/source/rpc_server/samr/dcesrv_samr.c
===================================================================
--- branches/SAMBA_4_0/source/rpc_server/samr/dcesrv_samr.c	2004-12-26 22:41:38 UTC (rev 4371)
+++ branches/SAMBA_4_0/source/rpc_server/samr/dcesrv_samr.c	2004-12-26 23:31:19 UTC (rev 4372)
@@ -1065,7 +1065,73 @@
 static NTSTATUS samr_LookupRids(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
 		       struct samr_LookupRids *r)
 {
-	DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+	struct dcesrv_handle *h;
+	struct samr_domain_state *d_state;
+	int i;
+	NTSTATUS status = NT_STATUS_OK;
+
+	ZERO_STRUCT(r->out.names);
+	ZERO_STRUCT(r->out.types);
+
+	DCESRV_PULL_HANDLE(h, r->in.domain_handle, SAMR_HANDLE_DOMAIN);
+
+	d_state = h->data;
+
+	if (r->in.num_rids == 0)
+		return NT_STATUS_OK;
+
+	r->out.names.names = talloc_array_p(mem_ctx, struct samr_String,
+					    r->in.num_rids);
+	if (r->out.names.names == NULL)
+		return NT_STATUS_NO_MEMORY;
+
+	r->out.types.ids = talloc_array_p(mem_ctx, uint32_t, r->in.num_rids);
+	if (r->out.types.ids == NULL)
+		return NT_STATUS_NO_MEMORY;
+
+	r->out.names.count = r->in.num_rids;
+	r->out.types.count = r->in.num_rids;
+
+	for (i=0; i<r->in.num_rids; i++) {
+		struct ldb_message **res;
+		int count;
+		const char * const attrs[] = { 	"sAMAccountType",
+						"sAMAccountName", NULL };
+		struct samr_String *str;
+		uint32_t atype;
+
+		str = &r->out.names.names[i];
+
+		ZERO_STRUCTP(str);
+		r->out.types.ids[i] = 0;
+
+		count = samdb_search(d_state->sam_ctx, mem_ctx,
+				     d_state->domain_dn, &res, attrs,
+				     "(objectSid=%s-%u)", d_state->domain_sid,
+				     r->in.rids[i]);
+		if (count != 1) {
+			status = STATUS_SOME_UNMAPPED;
+			continue;
+		}
+
+		str->string = samdb_result_string(res[0], "sAMAccountName",
+						  NULL);
+		
+		atype = samdb_result_uint(res[0], "sAMAccountType", 0);
+		if (atype == 0) {
+			status = STATUS_SOME_UNMAPPED;
+			continue;
+		}
+
+		r->out.types.ids[i] = samdb_atype_map(atype);
+		
+		if (r->out.types.ids[i] == SID_NAME_UNKNOWN) {
+			status = STATUS_SOME_UNMAPPED;
+			continue;
+		}
+	}
+	
+	return status;
 }
 
 



More information about the samba-cvs mailing list