summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2007-04-22 15:13:50 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:19:35 -0500
commit8040fec0accd93b7932c1c81520540ea46c33eb6 (patch)
treefb8eaba95817cc724bc4e71c0ea6c5224ee7532b /source3/libads
parent2541e0d59048f9d0f522aaebca4c4c6f5019fec5 (diff)
downloadsamba-8040fec0accd93b7932c1c81520540ea46c33eb6.tar.gz
samba-8040fec0accd93b7932c1c81520540ea46c33eb6.tar.bz2
samba-8040fec0accd93b7932c1c81520540ea46c33eb6.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 (This used to be commit 0475b8eea99ebb467e52225ad54f4302a77376b9)
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/ldap.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index b2ca68f67f..6707cbd4d0 100644
--- a/source3/libads/ldap.c
+++ b/source3/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