summaryrefslogtreecommitdiff
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
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
-rw-r--r--source4/dsdb/common/dsdb_dn.c42
-rw-r--r--source4/rpc_server/drsuapi/drsutil.c44
2 files changed, 42 insertions, 44 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;
+}
diff --git a/source4/rpc_server/drsuapi/drsutil.c b/source4/rpc_server/drsuapi/drsutil.c
index 5b5e14aea4..f88af93354 100644
--- a/source4/rpc_server/drsuapi/drsutil.c
+++ b/source4/rpc_server/drsuapi/drsutil.c
@@ -26,50 +26,6 @@
#include "param/param.h"
#include "auth/session.h"
-/*
- format a drsuapi_DsReplicaObjectIdentifier naming context as a string
- */
-char *drs_ObjectIdentifier_to_string(TALLOC_CTX *mem_ctx,
- struct drsuapi_DsReplicaObjectIdentifier *nc)
-{
- char *guid, *sid, *ret;
- guid = GUID_string(mem_ctx, &nc->guid);
- sid = dom_sid_string(mem_ctx, &nc->sid);
- ret = talloc_asprintf(mem_ctx, "<GUID=%s>;<SID=%s>;%s",
- guid, sid, nc->dn);
- talloc_free(guid);
- talloc_free(sid);
- return ret;
-}
-
-struct ldb_dn *drs_ObjectIdentifier_to_dn(TALLOC_CTX *mem_ctx,
- struct ldb_context *ldb,
- struct drsuapi_DsReplicaObjectIdentifier *nc)
-{
- char *guid = NULL, *sid = NULL, *ret = NULL;
- struct ldb_dn *new_dn;
- if (!GUID_all_zero(&nc->guid)) {
- guid = GUID_string(mem_ctx, &nc->guid);
- if (guid) {
- ret = talloc_asprintf_append(mem_ctx, "<GUID=%s>;", guid);
- }
- }
- if (nc->sid.sid_rev_num != 0) {
- sid = dom_sid_string(mem_ctx, &nc->sid);
- if (sid) {
- ret = talloc_asprintf_append(ret, "<SID=%s>;", sid);
- }
- }
- if (nc->dn) {
- ret = talloc_asprintf_append(ret, "%s", nc->dn);
- }
- new_dn = ldb_dn_new(mem_ctx, ldb, ret);
- talloc_free(guid);
- talloc_free(sid);
- talloc_free(ret);
- return new_dn;
-}
-
int drsuapi_search_with_extended_dn(struct ldb_context *ldb,
TALLOC_CTX *mem_ctx,
struct ldb_result **_res,