LDAP SCL Interface |
Searches and retrieves information from an LDAP directory.
_SEARCH(filter, attribs, results);
""
indicates that all attributes are to be returned.
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 entry. |
2 | Numeric | Number of attributes and values in 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 above) 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 |
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;
LDAP SCL Interface |