|
|
|
|
|
- Overview
- Retrieving information about the users
- 1. Connecting to the server that contains the Active Directory
- 2. Finding users
- 3. Close the session
Accessing an LDAP directory
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 lists network properties, user accounts, computers and more. It is often used to identify 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.
LDAPSession.Host = SAI_SERVEUR
LDAPSession.User = SAI_UTILISATEUR
LDAPSession.Password = SAI_MDP
LDAPConnect("MaSession")
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-secured LDAP: The LDAPSession structure can also be used to manage an SSL-secured 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).
sListeFils = LDAPListChildren("MaSession", "CN=Users,DC=tdf, DC=local")
FOR EACH STRING sUnFils OF sListeFils SEPARATED BY CR
sNom = LDAPValue("MaSession", sUnFils, "name")
sDescription = LDAPValue("MaSession", sUnFils, "description")
bAdministrateur = LDAPValue("MaSession", sUnFils, "adminCount")
END
Please note Depending on the LDAP strategies defined in Active Directory, import may 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("MaSession")
Related Examples:
|
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, ...
|
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|