summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-01-06 14:50:41 +1100
committerAndrew Tridgell <tridge@samba.org>2010-01-08 13:03:00 +1100
commit8cd2bedee74ae8dfb3a19f9bdde4a568de4b44cd (patch)
tree4ccb213c4ef4d7446cf9fb99c7e78e6638565309 /source4/dsdb
parent37340d5a2e04a194479beb80b96b0bc78df4393a (diff)
downloadsamba-8cd2bedee74ae8dfb3a19f9bdde4a568de4b44cd.tar.gz
samba-8cd2bedee74ae8dfb3a19f9bdde4a568de4b44cd.tar.bz2
samba-8cd2bedee74ae8dfb3a19f9bdde4a568de4b44cd.zip
s4-dsdb: added dsdb_find_guid_attr_by_dn()
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/common/util.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index 2b8a68e58f..70750ca141 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -2433,16 +2433,20 @@ int dsdb_search_dn_with_deleted(struct ldb_context *ldb,
/*
- use a DN to find a GUID
+ use a DN to find a GUID with a given attribute name
*/
-int dsdb_find_guid_by_dn(struct ldb_context *ldb,
- struct ldb_dn *dn, struct GUID *guid)
+int dsdb_find_guid_attr_by_dn(struct ldb_context *ldb,
+ struct ldb_dn *dn, const char *attribute,
+ struct GUID *guid)
{
int ret;
struct ldb_result *res;
- const char *attrs[] = { "objectGUID", NULL };
+ const char *attrs[2];
TALLOC_CTX *tmp_ctx = talloc_new(ldb);
+ attrs[0] = attribute;
+ attrs[1] = NULL;
+
ret = dsdb_search_dn_with_deleted(ldb, tmp_ctx, &res, dn, attrs);
if (ret != LDB_SUCCESS) {
talloc_free(tmp_ctx);
@@ -2452,11 +2456,20 @@ int dsdb_find_guid_by_dn(struct ldb_context *ldb,
talloc_free(tmp_ctx);
return LDB_ERR_NO_SUCH_OBJECT;
}
- *guid = samdb_result_guid(res->msgs[0], "objectGUID");
+ *guid = samdb_result_guid(res->msgs[0], attribute);
talloc_free(tmp_ctx);
return LDB_SUCCESS;
}
+/*
+ use a DN to find a GUID
+ */
+int dsdb_find_guid_by_dn(struct ldb_context *ldb,
+ struct ldb_dn *dn, struct GUID *guid)
+{
+ return dsdb_find_guid_attr_by_dn(ldb, dn, "objectGUID", guid);
+}
+
/*