diff options
author | Andrew Tridgell <tridge@samba.org> | 2001-12-04 12:08:16 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2001-12-04 12:08:16 +0000 |
commit | 3ec4a4def3f3a98606ad09ca9feaf366bae7fcb2 (patch) | |
tree | d4ac49c407bfdac8dbc79d165f69ef0089bb1ec7 /source3 | |
parent | 84503c81f0a48be06f5a73ee2334fc0f6824a78f (diff) | |
download | samba-3ec4a4def3f3a98606ad09ca9feaf366bae7fcb2.tar.gz samba-3ec4a4def3f3a98606ad09ca9feaf366bae7fcb2.tar.bz2 samba-3ec4a4def3f3a98606ad09ca9feaf366bae7fcb2.zip |
added ads_search_dn() and ads_pull_sids()
(This used to be commit bc83d55f4400cdcdfed44622954f11580b6d2f87)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/libads/ldap.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index 61d805ab86..50583146c0 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -88,6 +88,18 @@ int ads_search(ADS_STRUCT *ads, void **res, LDAP_SCOPE_SUBTREE, exp, (char **)attrs, 0, (LDAPMessage **)res); } +/* + do a search on a specific DistinguishedName +*/ +int ads_search_dn(ADS_STRUCT *ads, void **res, + const char *dn, + const char **attrs) +{ + *res = NULL; + return ldap_search_s(ads->ld, dn, + LDAP_SCOPE_BASE, "(objectclass=*)", (char **)attrs, 0, (LDAPMessage **)res); +} + /* find a machine account given a hostname @@ -434,6 +446,35 @@ BOOL ads_pull_sid(ADS_STRUCT *ads, return ret; } +/* + pull an array of DOM_SIDs from a ADS result + return the count of SIDs pulled +*/ +int ads_pull_sids(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, + void *msg, const char *field, DOM_SID **sids) +{ + struct berval **values; + BOOL ret; + int count, i; + + values = ldap_get_values_len(ads->ld, msg, field); + + if (!values) return 0; + + for (i=0; values[i]; i++) /* nop */ ; + + (*sids) = talloc(mem_ctx, sizeof(DOM_SID) * i); + + count = 0; + for (i=0; values[i]; i++) { + ret = sid_parse(values[i]->bv_val, values[i]->bv_len, &(*sids)[count]); + if (ret) count++; + } + + ldap_value_free_len(values); + return count; +} + /* find the update serial number - this is the core of the ldap cache */ BOOL ads_USN(ADS_STRUCT *ads, uint32 *usn) @@ -443,7 +484,7 @@ BOOL ads_USN(ADS_STRUCT *ads, uint32 *usn) void *res; rc = ldap_search_s(ads->ld, ads->bind_path, - LDAP_SCOPE_BASE, "(objectclass=*)", (char **)attrs, 0, (LDAPMessage **)&res); + LDAP_SCOPE_BASE, "(objectclass=*)", attrs, 0, (LDAPMessage **)&res); if (rc || ads_count_replies(ads, res) != 1) return False; return ads_pull_uint32(ads, res, "highestCommittedUSN", usn); } |