How to search/read LDAP User Store from ABAP

This article is guide on how-to work with LDAP User store from ABAP.

Prerequisites:

  1. TCP-IP Connection type is setup in SM59 for LDAP Connector
    • Open T.Code SM59, Create new connection type  'T' - TCP/IP Connection
    • When you successfully started the connector in the next step do a Unicode test (Utilities→Test→Unicode Test).
  2. Define default LDAP Server with system access stored in LDAP transaction
    1. 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 help
      • Click on Activate button to activate the LDAP Connector.
    2. Configure LDAP Server Setup as following:
    3. Test functionality in LDAP Transaction
      1. Click on Logon to establish the connection to LDAP server with defined system users.
      2. If everything is setup correctly, Status will be green:
      3. 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:

  1. Get default server id by FM  LDAP_VALID_SERVERID
  2. 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.
  3. Search the entries in LDAP by UserID using FM: LDAP_SEARCH  
  4.     
  5. If found, hence there will be records in return table DNS_OUT. Then we can use FM LDAP_READ to read details.
  6. Disconnect to LDAP server using FM  LDAP_UNBIND .