Add smbldap_pull_sid
authorVolker Lendecke <vl@samba.org>
Wed, 27 May 2009 23:02:40 +0000 (01:02 +0200)
committerVolker Lendecke <vl@samba.org>
Thu, 28 May 2009 08:52:04 +0000 (10:52 +0200)
source3/include/smbldap.h
source3/lib/smbldap.c
source3/libads/ldap.c

index 3ac770a548b462d376f7f9216812e676382b0ef2..c28d43d53ba9ebfd26c38513b610710618cb2161 100644 (file)
@@ -214,6 +214,8 @@ char * smbldap_talloc_single_attribute(LDAP *ldap_struct, LDAPMessage *entry,
 char * smbldap_talloc_smallest_attribute(LDAP *ldap_struct, LDAPMessage *entry,
                                         const char *attribute,
                                         TALLOC_CTX *mem_ctx);
+bool smbldap_pull_sid(LDAP *ld, LDAPMessage *msg, const char *attrib,
+                     struct dom_sid *sid);
 void talloc_autofree_ldapmsg(TALLOC_CTX *mem_ctx, LDAPMessage *result);
 void talloc_autofree_ldapmod(TALLOC_CTX *mem_ctx, LDAPMod **mod);
 char *smbldap_talloc_dn(TALLOC_CTX *mem_ctx, LDAP *ld,
index 4360d3ab578008860d61d4bba291bc4047af95ea..b6921c329c0301af3edb51795d4fbf0f19271b6a 100644 (file)
@@ -389,6 +389,26 @@ ATTRIB_MAP_ENTRY sidmap_attr_list[] = {
        return result;
 }
 
+ bool smbldap_pull_sid(LDAP *ld, LDAPMessage *msg, const char *attrib,
+                      struct dom_sid *sid)
+{
+       struct berval **values;
+       bool ret = False;
+
+       values = ldap_get_values_len(ld, msg, attrib);
+
+       if (!values) {
+               return false;
+       }
+
+       if (values[0] != NULL) {
+               ret = sid_parse(values[0]->bv_val, values[0]->bv_len, sid);
+       }
+
+       ldap_value_free_len(values);
+       return ret;
+}
+
  static int ldapmsg_destructor(LDAPMessage **result) {
        ldap_msgfree(*result);
        return 0;
index 588c0a131c37122490251a554167e173f29b0ca7..3e5764a598b369082f367ba4c0a9a8f2aed745cb 100644 (file)
@@ -2619,19 +2619,7 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
  bool ads_pull_sid(ADS_STRUCT *ads, LDAPMessage *msg, const char *field,
                   DOM_SID *sid)
 {
-       struct berval **values;
-       bool ret = False;
-
-       values = ldap_get_values_len(ads->ldap.ld, msg, field);
-
-       if (!values)
-               return False;
-
-       if (values[0])
-               ret = sid_parse(values[0]->bv_val, values[0]->bv_len, sid);
-       
-       ldap_value_free_len(values);
-       return ret;
+       return smbldap_pull_sid(ads->ldap.ld, msg, field, sid);
 }
 
 /**