ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Communication / LDAP functions
  • Overview
  • Retrieving information about the users
  • 1. Connecting to the server that contains the Active Directory
  • 2. Finding users
  • 3. Close the session
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
An LDAP directory is used to share information databases on a local or external network. This information directory can contain all kinds of information, personal details of persons or system data.
Active Directory is a standardized LDAP directory.
An Active Directory is used to list the properties of a network, the user accounts, the computers, ... It is often used to identify the users.
This help page explains how to retrieve information about the users stored in an LDAP directory.
Retrieving information about the users

1. Connecting to the server that contains the Active Directory

LDAP is based on a Client/Server architecture. Therefore, you must connect to the server that contains the Active Directory.
The connection requires the address of the server, the name of the user as well as his password.
These parameters are filled in the LDAPSession structure:
  • LDAPSession.Host for the server address.
  • LDAPSession.User for the username.
  • LDAPSession.Password for the password.
The connection is established by LDAPConnect.
// Fill the connection structure
LDAPSession.Host = EDT_SERVER
LDAPSession.User = EDT_USER
LDAPSession.Password =  EDT_PWD
// Connection to the LDAP server
LDAPConnect("MySession")
Remarks:
  • LDAPConnect uses the parameter filled in the LDAPSession structure. Then, all you have to do is pass as parameter the name that will be given to the session. Several sessions can be opened at the same time, under different names.
  • LDAPReset is used to reinitialize all the variables of the LDAPSession structure.
  • SSL-secure LDAP: The LDAPSession structure can also be used to manage a SSL secure connection via the LDAPSession.Option variable. For more details, see LDAPSession structure.

2. Finding users

LDAP is an information database. This information database is organized in a tree-like structure. It is made of elements that can themselves contain other elements. Each element has properties. Each element is identified via a unique name (Distinguished Name).
LDAPListChildren is used to list the element children (which means the elements found in this element).
To retrieve the elements of the Users DN (that contains all the users), the following parameters must be passed as parameter to LDAPListChildren:
  • The connection name (defined by LDAPConnect),
  • The DN of the Users element. For an Active Directory, the DN for retrieving the users will always be the same.
LDAPListChildren returns a string. This string contains the identifiers of all the children found separated by CR characters (Carriage Return).
Therefore, all you have to do is browse the returned string to retrieve each child one by one. Then, LDAPValue lets you retrieve the value of an element's property, that is:
  • the username (Name property),
  • the description (Description property),
  • the Administrator property (AdminCount property).
// List the users
sListChildren = LDAPListChildren("MySession", "CN=Users,DC=tdf, DC=local")
// For all the users found
FOR EACH STRING sChild OF sChildrenList SEPARATED BY CR
// Retrieve the properties of this user (name, description, administrator)
sName = LDAPValue("MySession", sAChild, "name")
sDescription = LDAPValue("MySession", sAChild, "description")
bAdministrator = LDAPValue("MySession", sAChild, "adminCount")
END
Caution: depending on the LDAP policies defined in Active Directory, the import can be limited to 1,000 users. In this case, to remove this limitation, it is necessary to modify the LDAP MaxPageSize parameter. For more details, see https://support.microsoft.com/kb/315071.

3. Close the session

LDAPDisconnect is used to end the LDAP session.
// Disconnection
LDAPDisconnect("MySession")
Related Examples:
The LDAP functions Unit examples (WINDEV): The LDAP functions
[ + ] Using the WLanguage LDAP functions.
These functions are used to interact with the LDAP data, to view the content of any LDAP directory and to modify the LDAP data: LDAPConnect, LDAPListChildren, LDAPAdAttribute, LDAPDeleteAttributeValue, ...
Minimum version required
  • Version 10
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/22/2023

Send a report | Local help