summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2007-07-11 10:26:02 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:28:31 -0500
commite7705f9eb920715b95a331e2f3c1f1c60258ac18 (patch)
tree22a261f3387e7af006975ff40a6869d5ab62833a /source3/libads
parentf0072e54767de3c964ee3c9ed732ab0b58d05004 (diff)
downloadsamba-e7705f9eb920715b95a331e2f3c1f1c60258ac18.tar.gz
samba-e7705f9eb920715b95a331e2f3c1f1c60258ac18.tar.bz2
samba-e7705f9eb920715b95a331e2f3c1f1c60258ac18.zip
r23829: Add ads_get_attrname_by_guid().
Guenther (This used to be commit a84fd8300661fd895ed7a8a104b743628718dfc8)
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/ldap_schema.c53
1 files changed, 51 insertions, 2 deletions
diff --git a/source3/libads/ldap_schema.c b/source3/libads/ldap_schema.c
index f71f53adb6..2672d88306 100644
--- a/source3/libads/ldap_schema.c
+++ b/source3/libads/ldap_schema.c
@@ -1,7 +1,7 @@
/*
Unix SMB/CIFS implementation.
ads (active directory) utility library
- Copyright (C) Guenther Deschner 2005-2006
+ Copyright (C) Guenther Deschner 2005-2007
Copyright (C) Gerald (Jerry) Carter 2006
This program is free software; you can redistribute it and/or modify
@@ -106,6 +106,56 @@ out:
return status;
}
+const char *ads_get_attrname_by_guid(ADS_STRUCT *ads,
+ const char *schema_path,
+ TALLOC_CTX *mem_ctx,
+ const char *schema_guid)
+{
+ ADS_STATUS rc;
+ LDAPMessage *res = NULL;
+ char *expr = NULL;
+ const char *attrs[] = { "lDAPDisplayName", NULL };
+ const char *result = NULL;
+ struct GUID guid;
+ char *guid_bin = NULL;
+
+ if (!ads || !mem_ctx || !schema_guid) {
+ goto done;
+ }
+
+ if (!NT_STATUS_IS_OK(GUID_from_string(schema_guid, &guid))) {
+ goto done;
+ }
+
+ guid_bin = guid_binstring(&guid);
+ if (!guid_bin) {
+ goto done;
+ }
+
+ expr = talloc_asprintf(mem_ctx, "(schemaIDGUID=%s)", guid_bin);
+ if (!expr) {
+ goto done;
+ }
+
+ rc = ads_do_search_retry(ads, schema_path, LDAP_SCOPE_SUBTREE,
+ expr, attrs, &res);
+ if (!ADS_ERR_OK(rc)) {
+ goto done;
+ }
+
+ if (ads_count_replies(ads, res) != 1) {
+ goto done;
+ }
+
+ result = ads_pull_string(ads, mem_ctx, res, "lDAPDisplayName");
+
+ done:
+ SAFE_FREE(guid_bin);
+ ads_msgfree(ads, res);
+ return result;
+
+}
+
const char *ads_get_attrname_by_oid(ADS_STRUCT *ads, const char *schema_path, TALLOC_CTX *mem_ctx, const char * OID)
{
ADS_STATUS rc;
@@ -147,7 +197,6 @@ failed:
ads_msgfree(ads, res);
return NULL;
}
-
/*********************************************************************
*********************************************************************/