summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-09-28 10:39:52 -0700
committerAndrew Tridgell <tridge@samba.org>2010-09-28 11:36:40 -0700
commitd4939ce4fc5e61c96e047b6a61a5502335da8926 (patch)
tree11e976a289377ba141a05f02ac569df0dd010c73 /source4/dsdb
parentcd3eddbb59a21534f5a854b9a1fb1419530cca3f (diff)
downloadsamba-d4939ce4fc5e61c96e047b6a61a5502335da8926.tar.gz
samba-d4939ce4fc5e61c96e047b6a61a5502335da8926.tar.bz2
samba-d4939ce4fc5e61c96e047b6a61a5502335da8926.zip
s4-drs: moved the drs_ObjectIdentifier handling to dsdb_dn.c
this will be used outside of the drs server. This also fixes the handling of the ndr_size elements of the drs_ObjectIdentifier
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/common/dsdb_dn.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/source4/dsdb/common/dsdb_dn.c b/source4/dsdb/common/dsdb_dn.c
index cb9cb299ce..85ba9b7605 100644
--- a/source4/dsdb/common/dsdb_dn.c
+++ b/source4/dsdb/common/dsdb_dn.c
@@ -22,6 +22,8 @@
#include "includes.h"
#include "dsdb/samdb/samdb.h"
#include "lib/ldb/include/ldb_module.h"
+#include "librpc/ndr/libndr.h"
+#include "libcli/security/dom_sid.h"
enum dsdb_dn_format dsdb_dn_oid_to_format(const char *oid)
{
@@ -402,3 +404,43 @@ WERROR dsdb_dn_la_from_blob(struct ldb_context *sam_ctx,
return WERR_OK;
}
+
+
+/*
+ format a drsuapi_DsReplicaObjectIdentifier naming context as a string
+ */
+char *drs_ObjectIdentifier_to_string(TALLOC_CTX *mem_ctx,
+ struct drsuapi_DsReplicaObjectIdentifier *nc)
+{
+ char *ret = NULL;
+ TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+ if (!GUID_all_zero(&nc->guid)) {
+ char *guid = GUID_string(tmp_ctx, &nc->guid);
+ if (guid) {
+ ret = talloc_asprintf_append(ret, "<GUID=%s>;", guid);
+ }
+ }
+ if (nc->__ndr_size_sid != 0 && nc->sid.sid_rev_num != 0) {
+ const char *sid = dom_sid_string(tmp_ctx, &nc->sid);
+ if (sid) {
+ ret = talloc_asprintf_append(ret, "<SID=%s>;", sid);
+ }
+ }
+ if (nc->__ndr_size_dn != 0 && nc->dn) {
+ ret = talloc_asprintf_append(ret, "%s", nc->dn);
+ }
+ talloc_free(tmp_ctx);
+ talloc_steal(mem_ctx, ret);
+ return ret;
+}
+
+struct ldb_dn *drs_ObjectIdentifier_to_dn(TALLOC_CTX *mem_ctx,
+ struct ldb_context *ldb,
+ struct drsuapi_DsReplicaObjectIdentifier *nc)
+{
+ char *dn_string = drs_ObjectIdentifier_to_string(mem_ctx, nc);
+ struct ldb_dn *new_dn;
+ new_dn = ldb_dn_new(mem_ctx, ldb, dn_string);
+ talloc_free(dn_string);
+ return new_dn;
+}