| LDAP SCL Interface |
| Syntax | |
| Arguments | |
| Details | |
| Examples |
Syntax |
| _SEARCH(filter, attribs, results); |
| filter |
specifies search criteria that determine that the entries are to be added to the entry list returned by the search.
| ||||
| attribs |
specifies in an SCL list the names of the attributes to be returned in the search results for each entry that matches the search criteria. The value 0 indicates that all attributes are to be returned.
| ||||
| results |
returns the results of the search.
|
| Details |
When invoked on an LDAPSERVICES instance, the _SEARCH method allows you to select and retrieve entries from an LDAP directory.
The content returned in the results parameter is a list of SCL lists containing the entries, attributes, and values that match the search criteria. Each entry in the entry list contains a sublist in the following format:
| Item | Type | Value |
|---|---|---|
| 1 | Character | Distinguished name of an entry. |
| 2 | Numeric | Number of attributes and values in an entry. |
| 3 | SCL list | Attribute name and values. |
| ... | SCL list | Attribute name and values. |
| num_attrs+2 | SCL list | Attribute name and values. |
The SCL list that contains the attribute names and values (see item 3 in Table 3.1) has the following format:
| Item | Type | Value |
|---|---|---|
| 1 | Character | Attribute name |
| 2 | Numeric | Number of values returned for this attribute |
| 3 | Character | Attribute value |
| ... | Character | Attribute value |
| num_values+2 | Character | Attribute value |
Note: This method should not be used to retrieve internal attributes
from a Microsoft Active Directory server. ![[cautionend]](../../../../common/61991/HTML/default/images/cautend.gif)
| Examples |
For 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;
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.