PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Retrieving information about the users
  • 1. Connecting to the server that contains the Active Directory
  • 2. Finding users
  • 3. Closing the session
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
An LDAP directory allows you 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 allows you 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 user name.
  • 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")
Notes:
  • LDAPConnect is using the parameter filled in the LDAPSession structure. Then, all you have to do is pass in 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.
  • Versions 19 and later
    SSL-secure LDAP: The LDAPSession structure can also be used to manage a SSL secure connection via the LDAPSession.Option variable. See LDAPSession structure for more details.
    New in version 19
    SSL-secure LDAP: The LDAPSession structure can also be used to manage a SSL secure connection via the LDAPSession.Option variable. See LDAPSession structure for more details.
    SSL-secure LDAP: The LDAPSession structure can also be used to manage a SSL secure connection via the LDAPSession.Option variable. See LDAPSession structure for more details.

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 in 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 is used to retrieve the value of an element property, which means:
  • the user name (Name property),
  • the description (Description property),
  • the Administrator property (AdminCount property).
// Lists 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

3. Closing 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 required version
  • Version 10
This page is also available for…
Comments
Click [Add] to post a comment