summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-09-23 13:52:39 -0700
committerAndrew Tridgell <tridge@samba.org>2009-09-23 14:01:29 -0700
commit6fba3a22fecc8126fb2f8aa4c518dbf0bbfdef80 (patch)
tree3b18747264556f0efed26c38a50733d0ea70c205
parentaf4c1f7fc67173e21b50797fd9de7e68602a97ed (diff)
downloadsamba-6fba3a22fecc8126fb2f8aa4c518dbf0bbfdef80.tar.gz
samba-6fba3a22fecc8126fb2f8aa4c518dbf0bbfdef80.tar.bz2
samba-6fba3a22fecc8126fb2f8aa4c518dbf0bbfdef80.zip
s4-dsdb: added dsdb_find_sid_by_dn()
-rw-r--r--source4/dsdb/common/util.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index 126f9fa829..9a49417d91 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -1609,6 +1609,7 @@ int samdb_search_for_parent_domain(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
if (res->count != 1) {
*errstring = talloc_asprintf(mem_ctx, "Invalid dn (%s), not child of a domain object",
ldb_dn_get_linearized(dn));
+ DEBUG(0,(__location__ ": %s\n", *errstring));
talloc_free(local_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
@@ -2205,6 +2206,35 @@ int dsdb_find_guid_by_dn(struct ldb_context *ldb,
return LDB_SUCCESS;
}
+/*
+ use a DN to find a SID
+ */
+int dsdb_find_sid_by_dn(struct ldb_context *ldb,
+ struct ldb_dn *dn, struct dom_sid *sid)
+{
+ int ret;
+ struct ldb_result *res;
+ const char *attrs[] = { "objectSID", NULL };
+ TALLOC_CTX *tmp_ctx = talloc_new(ldb);
+ struct dom_sid *s;
+
+ ZERO_STRUCTP(sid);
+
+ ret = ldb_search(ldb, tmp_ctx, &res, dn, LDB_SCOPE_BASE, attrs, NULL);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(tmp_ctx);
+ return ret;
+ }
+ s = samdb_result_dom_sid(tmp_ctx, res->msgs[0], "objectSID");
+ if (s == NULL) {
+ talloc_free(tmp_ctx);
+ return LDB_ERR_NO_SUCH_OBJECT;
+ }
+ *sid = *s;
+ talloc_free(tmp_ctx);
+ return LDB_SUCCESS;
+}
+
/*