summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-08-31 04:15:37 +0300
committerKamen Mazdrashki <kamenim@samba.org>2010-09-03 13:23:48 +0300
commit3691e6c97b2187730d42a2bb79ecc06f37aab344 (patch)
tree57c5e8d70fa525319f576f5fd39c2f8666384b8b /source4/dsdb
parent5685fb64e4f4660d586e57c59800d0f374d10749 (diff)
downloadsamba-3691e6c97b2187730d42a2bb79ecc06f37aab344.tar.gz
samba-3691e6c97b2187730d42a2bb79ecc06f37aab344.tar.bz2
samba-3691e6c97b2187730d42a2bb79ecc06f37aab344.zip
s4-dreplsrv: Helper to find NC by DN or GUID or SID
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/repl/drepl_partitions.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/source4/dsdb/repl/drepl_partitions.c b/source4/dsdb/repl/drepl_partitions.c
index 5a11dce50f..c388a4b516 100644
--- a/source4/dsdb/repl/drepl_partitions.c
+++ b/source4/dsdb/repl/drepl_partitions.c
@@ -31,6 +31,7 @@
#include "librpc/gen_ndr/ndr_misc.h"
#include "librpc/gen_ndr/ndr_drsuapi.h"
#include "librpc/gen_ndr/ndr_drsblobs.h"
+#include "libcli/security/dom_sid.h"
#include "param/param.h"
WERROR dreplsrv_load_partitions(struct dreplsrv_service *s)
@@ -234,6 +235,38 @@ static WERROR udv_convert(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
+WERROR dreplsrv_partition_find_for_nc(struct dreplsrv_service *s,
+ const struct GUID *nc_guid,
+ const struct dom_sid *nc_sid,
+ const char *nc_dn_str,
+ struct dreplsrv_partition **_p)
+{
+ struct dreplsrv_partition *p;
+ bool valid_sid, valid_guid;
+ struct dom_sid null_sid;
+ ZERO_STRUCT(null_sid);
+
+ SMB_ASSERT(_p);
+
+ valid_sid = nc_sid && !dom_sid_equal(&null_sid, nc_sid);
+ valid_guid = nc_guid && !GUID_all_zero(nc_guid);
+
+ if (!valid_sid && !valid_guid && !nc_dn_str) {
+ return WERR_DS_DRA_INVALID_PARAMETER;
+ }
+
+ for (p = s->partitions; p; p = p->next) {
+ if ((valid_guid && GUID_equal(&p->nc.guid, nc_guid))
+ || strequal(p->nc.dn, nc_dn_str)
+ || (valid_sid && dom_sid_equal(&p->nc.sid, nc_sid)))
+ {
+ *_p = p;
+ return WERR_OK;
+ }
+ }
+
+ return WERR_DS_DRA_BAD_NC;
+}
static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
struct dreplsrv_partition *p)