Directory Services
LDAPS_SEARCHSearches and retrieves information from the specified LDAP directory. SyntaxCALL LDAPS_SEARCH(lHandle, sHandle, filter, attributes, numEntries, rc);
DetailsThe LDAPS_SEARCH CALL routine selects and retrieves entries from a specified LDAP directory. A search handle is returned so that information about specific entries and attributes can be obtained. The search information identified by the search handle can be used until it is explicitly freed using the LDAPS_FREE call routine or until the connection is closed using the LDAPS_CLOSE call routine. Note: This CALL routine should not be used to retrieve internal attributes from a Microsoft Active Directory server. ExamplesThe following example returns a list of entries on the LDAP server that match the values of the specified filter. The list of entries returned from the search includes the values of two attributes for each matching entry. filter="(&(saschannelcn=DeleteTest)(objectclass=*))"; attrs="description objectclass"; rc=0; numEntries=0; sHandle=0; call LDAPS_SEARCH(lhandle, sHandle, filter, attrs, numEntries, rc); The following example prints to the SAS log the names and values of all attributes in all entries in a given LDAP directory. call LDAPS_SEARCH(lhandle, sHandle, filter, attribs, numEntries, rc); do entryIndex = 1 to numEntries; numAttributes = 0; entryName=''; /* retrieve entry indexed by integer entryIndex */ call ldaps_entry(sHandle, entryIndex, entryName, numAttributes, rc); put 'Entry name is ' entryName; put 'Number of attributes returned is ' numAttributes; do attrIndex = 1 to numAttributes; call ldaps_attrname (sHandle,entryIndex, attrIndex, attribName, numValues, rc); do attrValueIndex = 1 to numValues; call ldaps_attrvalue (sHandle, entryIndex, attrindex, attrValueIndex, value, rc); put "Attribute value is " value; end; end; end; |