|
Directory Services
_SEARCHSearches and retrieves information from an LDAP directory. Syntax_SEARCH(filter, attribs, results);
DetailsWhen invoked on an LDAPSERVICES instance, the _SEARCH method allows you to select and retrieve entries from an LDAP directory.
The content returned in the
The SCL list that contains the attribute names and values (see item 3 above) has the following format:
Note: This method should not be used to retrieve internal attributes from a Microsoft Active Directory server. ExamplesFor a single LDAP directory entry, the following example returns four attributes and the values of those attributes. /* list of attributes to be returned */ attribs = makelist(); rc = insertc(attribs, "uid", -1); rc = insertc(attribs, "mail", -1); rc = insertc(attribs, "roomnumber", -1); rc = insertc(attribs, "employeenumber", -1); r = makelist(); /* results returned in r */ rc = ds._SEARCH('cn=John Smith', attribs, r); The following example searches an LDAP directory and extracts from the search results the attribute names and all the values of those attributes. results=makelist(); rc = dirInst._SEARCH(filter, attribs, results); total_entries = listlen(results); do i = 1 to total_entries; /* each list in results is entry matching criteria */ entry = getiteml(results, i); /* distinguished name */ dn = getitemc(entry, 1); /* total number of attributes returned */ attribNum = getitemn(entry, 2); do k= 3 to (attribNum+2); /* each attribute is its own list, get first attrib */ attrib = getiteml(entry, k); /* name of attribute */ attribname = getitemc(attrib,1 ); /* number of values */ numValues = getitemn(attrib, 2); /* retrieve values */ do z = 3 to (numValues + 2); value = getitemc(attrib, z); end; end; end; |