How to search/read LDAP User Store from ABAP
This article is guide on how-to work with LDAP User store from ABAP.
Prerequisites:
TCP-IP Connection type is setup in SM59 for LDAP Connector
Open T.Code SM59, Create new connection type 'T' - TCP/IP ConnectionWhen you successfully started the connector in the next step do a Unicode test (Utilities→Test→Unicode Test).Define default LDAP Server with system access stored in LDAP transaction
Click on LDAP Connector button and enter following details. Click on Activate Button to activate the LDAP Connector.
The connector Name is the same as RFC Program ID, this can be selected by Standard search helpClick on Activate button to activate the LDAP Connector.Configure LDAP Server Setup as following:
Test functionality in LDAP Transaction
Click on Logon to establish the connection to LDAP server with defined system users.
If everything is setup correctly, Status will be green:
You can test to query entries from LDAP by using Find function
Instructions
After the configuration is done, you access LDAP data programmatically as following:
Get default server id by FM LDAP_VALID_SERVERID
Establish the connection to LDAP server by server id found in Step 1 using FM LDAP_SYSTEMBIND. This will use the stored System users defined in LDAP configuration.
Search the entries in LDAP by UserID using FM: LDAP_SEARCH
If found, hence there will be records in return table DNS_OUT. Then we can use FM LDAP_READ to read details.
Disconnect to LDAP server using FM LDAP_UNBIND .