Skip to Content
Author's profile photo Craig Cmehil

BSP / HowTo: Fun with LDAP and BSP’s

Recently, OK yesterday I needed to connect to a LDAP server and look at the values stored there, but I didn’t know how. So I went to work, figured it out and here is the result for everyone else who might be interested.


First things first, you need a LDAP server. We use Siemens DirX. I talked to our LDAP master and he told me the connection settings and then I went to the Help website and looked at the docs on how to connect the LDAP to the system. At first I was expecting some long horrible process of configuration and settings. Boy, was I surprised!
As you can see I gave the BASE in hard coded as well which in this LDAP test server is just a simple tree structure. Oh and take out the space before and after the br in the CONCATENATE statement. I had to put it like that for the weblog since I didn’t want to load each of these sections into separate textareas.

Here’s the complete code for the Event Handler.


So now you have the complete code as well as hopefully an understanding of each section of it. You’ll notice that I actually give various numeric results to Result this is simply so I can see at which point an error comes if one comes.

    • 0 = OK
    • 1 = Not found in LDAP
    • 2 = No Connection
    • 3 = No search string given

So that’s about it, I’ve since gone on to enhance my “test” page with putting the results into a table for a nicer output but I think you’ll get the idea just the same with this example.


image

Assigned tags

      10 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      This was just what i was looking for. Simple and very fast to develop.
      Author's profile photo Former Member
      Former Member
      Your welcome!! Glad you got a use out of it! As I said that is the base and there are many other LDAP FM's available however with this base you can easily expand it to a real application. I have already began expanding ours to a large degree.

      Craig

      Author's profile photo Former Member
      Former Member
      Hi ,
      I tried the code in IDES.

      Function Module LDAP_SIMPLE_BIND works correctly and gives sy-subrc = 0. But LDAP_SEARCH raises exception "connection out date" sy-subrc = 2.

      I have configured the LDAP connection and the test connection results in no errors. I have connected the WAS to a non R/3 system.

      Can you please help me in this ... Are there any BASIS parameters to be set like "Auto Time out " for LDAP?

      Thanks in Advance,
      Regards,

      Laxman Nayak.

      Author's profile photo Former Member
      Former Member
      Do the standard LDAP functions and search in the system work?
      Author's profile photo Brian McKellar
      Brian McKellar
      Craig, even before I had time to read this weblog, some asked me about LDAP. I just referenced him to your weblog. It was no mistake. Just reading this “introduction” to LDAP quickly shows what is possible, and roughly the road to follow to a complete solution. Your weblog quickly helps one to find the starting point, which is already half the problem solved. Definitely a weblog to reference when the question comes up again (which it will:).
      brian
      Author's profile photo Former Member
      Former Member
      Thanks Brian!!!
      Author's profile photo Former Member
      Former Member
      Hi,

      you explained very good how to access the LDAP Direcotry.
      My question is now, how does the ldap directory transfer the data back to the HR.
      For example, if another application modifies an existing data record. So there is the need, that the data record in the R/3 will be updated.

      kind regards,
      Michele

      Author's profile photo Former Member
      Former Member
      You should check out this thread for more info 🙂

      SAP R/3 - LDAP athentication

      or

      SAP HR-LDAP in 46C

      Author's profile photo Former Member
      Former Member
      I am not able to change the password for a user. I tried various ways and my input is not accepted. Any ideas?
      Author's profile photo Former Member
      Former Member
      From my understanding, we don't do this, the passwords are encrypted and require you do process them the same way as the LDAP server would or the R/3 system would.

      You might trying searching the OSS notes for "LDAP" and "Password". If I get a free minute I will check as well.