diff options
author | Günther Deschner <gd@samba.org> | 2007-04-22 15:13:50 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:19:35 -0500 |
commit | 0475b8eea99ebb467e52225ad54f4302a77376b9 (patch) | |
tree | 82def724e50f9b5b549e97e9ba3f01689a18f8cc /source/libads | |
parent | f5ccec42287cfdf128bbfcf562a47a852bd0e3fe (diff) | |
download | samba-0475b8eea99ebb467e52225ad54f4302a77376b9.tar.gz samba-0475b8eea99ebb467e52225ad54f4302a77376b9.tar.xz samba-0475b8eea99ebb467e52225ad54f4302a77376b9.zip |
r22459: Adding ads_get_dn_from_extended_dn(), in preparation of making ranged LDAP
queries more generic. Michael, feel free to overwrite these and the following.
Guenther
Diffstat (limited to 'source/libads')
-rw-r--r-- | source/libads/ldap.c | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/source/libads/ldap.c b/source/libads/ldap.c index b2ca68f67fe..6707cbd4d0f 100644 --- a/source/libads/ldap.c +++ b/source/libads/ldap.c @@ -2678,23 +2678,57 @@ ADS_STATUS ads_upn_suffixes(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, char ***suffix } /** + * pull a dn from an extended dn string + * @param mem_ctx TALLOC_CTX + * @param extended_dn string + * @param dn pointer to the dn + * @return boolean inidicating success + **/ +BOOL ads_get_dn_from_extended_dn(TALLOC_CTX *mem_ctx, + const char *extended_dn, + char **dn) +{ + char *p; + pstring tok; + + if (!extended_dn) { + return False; + } + + while (next_token(&extended_dn, tok, ";", sizeof(tok))) { + p = tok; + } + + if ((*dn = talloc_strdup(mem_ctx, p)) == NULL) { + return False; + } + + return True; +} + +/** * pull a DOM_SID from an extended dn string * @param mem_ctx TALLOC_CTX + * @param extended_dn string * @param flags string type of extended_dn * @param sid pointer to a DOM_SID * @return boolean inidicating success **/ BOOL ads_get_sid_from_extended_dn(TALLOC_CTX *mem_ctx, - const char *dn, + const char *extended_dn, enum ads_extended_dn_flags flags, DOM_SID *sid) { - char *p, *q; + char *p, *q, *dn; - if (!dn) { + if (!extended_dn) { return False; } + /* otherwise extended_dn gets stripped off */ + if ((dn = talloc_strdup(mem_ctx, extended_dn)) == NULL) { + return False; + } /* * ADS_EXTENDED_DN_HEX_STRING: * <GUID=238e1963cb390f4bb032ba0105525a29>;<SID=010500000000000515000000bb68c8fd6b61b427572eb04556040000>;CN=gd,OU=berlin,OU=suse,DC=ber,DC=suse,DC=de |