summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-01-03 17:28:09 +0100
committerGünther Deschner <gd@samba.org>2008-01-03 18:15:59 +0100
commitb076a7e802a89bdc5b369e98c7d69d8f970d8265 (patch)
treedfaa9672614b511a186754c554e05912bc5e4e19 /source3/libads
parent192700bd08ba893cad9fb38f80231ad7cf9eb89f (diff)
downloadsamba-b076a7e802a89bdc5b369e98c7d69d8f970d8265.tar.gz
samba-b076a7e802a89bdc5b369e98c7d69d8f970d8265.tar.bz2
samba-b076a7e802a89bdc5b369e98c7d69d8f970d8265.zip
Add ads_get_joinable_ous().
Guenther (This used to be commit 5bbceac88159ef6ff83d9cc62c77c7af2116967d)
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/ldap.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 953693ce48..843d57988c 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -2791,6 +2791,66 @@ ADS_STATUS ads_upn_suffixes(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, char ***suffix
}
/**
+ * get the joinable ous for a domain
+ * @param ads connection to ads server
+ * @param mem_ctx Pointer to talloc context
+ * @param ous Pointer to an array of ous
+ * @param num_ous Pointer to the number of ous
+ * @return status of search
+ **/
+ADS_STATUS ads_get_joinable_ous(ADS_STRUCT *ads,
+ TALLOC_CTX *mem_ctx,
+ char ***ous,
+ size_t *num_ous)
+{
+ ADS_STATUS status;
+ LDAPMessage *res = NULL;
+ LDAPMessage *msg = NULL;
+ const char *attrs[] = { "dn", NULL };
+ int count = 0;
+
+ status = ads_search(ads, &res,
+ "(|(objectClass=domain)(objectclass=organizationalUnit))",
+ attrs);
+ if (!ADS_ERR_OK(status)) {
+ return status;
+ }
+
+ count = ads_count_replies(ads, res);
+ if (count < 1) {
+ ads_msgfree(ads, res);
+ return ADS_ERROR(LDAP_NO_RESULTS_RETURNED);
+ }
+
+ for (msg = ads_first_entry(ads, res); msg;
+ msg = ads_next_entry(ads, msg)) {
+
+ char *dn = NULL;
+
+ dn = ads_get_dn(ads, msg);
+ if (!dn) {
+ ads_msgfree(ads, res);
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
+
+ if (!add_string_to_array(mem_ctx, dn,
+ (const char ***)ous,
+ (int *)num_ous)) {
+ ads_memfree(ads, dn);
+ ads_msgfree(ads, res);
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
+
+ ads_memfree(ads, dn);
+ }
+
+ ads_msgfree(ads, res);
+
+ return status;
+}
+
+
+/**
* pull a DOM_SID from an extended dn string
* @param mem_ctx TALLOC_CTX
* @param extended_dn string