This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v20.6
LDAP Search
|
LDAP Search ( dnRootEntry ; filter {; scope {; attributes {; attributesAsArray}}} ) -> Function result | ||||||||
Parameter | Type | Description | ||||||
dnRootEntry | String |
![]() |
Distinguished Name of root entry where search is to start | |||||
filter | String |
![]() |
LDAP search filter | |||||
scope | String |
![]() |
Scope of search: "base" (default), "one", or "sub" | |||||
attributes | Text array |
![]() |
Attribute(s) to fetch | |||||
attributesAsArray | Boolean array |
![]() |
True = force attributes to be returned as array; False = force attributes to be returned as a simple variable | |||||
Function result | Object |
![]() |
Key/value attributes | |||||
The LDAP Search command searches in the target LDAP server for the first occurrence matching the criteria defined. This command must be executed within a connection to an LDAP server opened with LDAP LOGIN; otherwise a 1003 error is returned.
In dnRootEntry, pass the Distinguished Name of the LDAP server root entry; the search will start at this entry.
In filter, pass the LDAP search filter to execute. The filter string must be compliant with rfc2225. You can pass an empty string "" in order not to filter the search; the "*" is supported to search substrings.
In scope, pass one of the following constants from the "LDAP" theme:
Constant | Type | Value | Comment |
LDAP all levels | String | sub | Search in the root entry level defined by dnRootEntry and in all subsequent entries |
LDAP root and next | String | one | Search in the root entry level defined by dnRootEntry and in the directly subsequent entries on one level |
LDAP root only | String | base | Search only in the root entry level defined by dnRootEntry (default if omitted) |
Note: Keep in mind that LDAP attribute names are case-sensitive. For more information on LDAP attributes, you can refer to this page that lists all available attributes for the MS Active directory.
By default, the command returns attributes as a collection if multiple results are found, or as a variable if a single result is found. The optional attributesAsArray parameter allows you to "force" returned attribute(s) to be formatted as a collection or as a variable for each attribute defined:
You want to get the phone number of the user "smith" in the company directory:
ARRAY TEXT($_tabAttributes;0)
APPEND TO ARRAY($_tabAttributes;"cn")
APPEND TO ARRAY($_tabAttributes;"phoneNumber")
LDAP LOGIN($url;$dn;$pwd)
$filter:="cn=*smith*"
$vfound:=LDAP Search($dnSearchRootEntry;$filter;LDAP all levels;$_tabAttributes)
LDAP LOGOUT
We want to get an array of all entries found for the "memberOf" attribute:
C_OBJECT($entry)
ARRAY TEXT($_tabAttributes;0)
ARRAY BOOLEAN($_tabAttributes_asArray;0)
APPEND TO ARRAY($_tabAttributes;"cn")
APPEND TO ARRAY($_tabAttributes_asArray;False)
APPEND TO ARRAY($_tabAttributes;"memberOf")
APPEND TO ARRAY($_tabAttributes_asArray;True)
LDAP LOGIN($url;$login;$pwd;LDAP password plain text)
$entry:=LDAP Search($dnSearchRootEntry;"cn=adrien*";LDAP all levels;$_tabAttributes;$_tabAttributes_asArray)
LDAP LOGOUT
ARRAY TEXT($_arrMemberOf;0)
OB GET ARRAY($entry;"memberOf";$_arrMemberOf)
// in $_arrMemberOf we have an array containing all entry groups
Product: 4D
Theme: LDAP
Number:
1328
Created: 4D v15
4D Language Reference ( 4D v20)
4D Language Reference ( 4D v20.1)
4D Language Reference ( 4D v20.2)
4D Language Reference ( 4D v20.3)
4D Language Reference ( 4D v20.4)
4D Language Reference ( 4D v20.5)
4D Language Reference ( 4D v20.6)