0

I have a drupal install that uses LDAP to authenticate users. I use that same LDAP to return user info such as roles, employee photo, email, role, and the center they work at.

    $ds=ldap_connect("ldap-example.com");  
            if ($ds) { 
                $r=ldap_bind($ds);     
                $sr=ldap_search($ds, "DC=tpcontact,DC=co,DC=uk",$search);  
                $info = ldap_get_entries($ds, $sr)or die('get info fail');
}

I need to make it so that the server is pulled from drupal. So, if it is possible to query ldap without reconnecting, I need to do that. Otherwise I need to query the drupal DB's ldap_servers table, the only problem is that I dont have access to a MySql database that has LDAP enabled to see what the field is.

4
  • can you reword this question to be more clear. Your question doesn't make much sense. Any time you want to query mysql or ldap you have to connect first. A connection only last the duration of a single url page request from a site visitor.
    – tenken
    Commented Feb 21, 2014 at 16:24
  • I've updated my answer with the name of the field that contains the address...
    – Felix Eve
    Commented Feb 21, 2014 at 16:56
  • 1
    ok, i see you know the ldap_query, ldap_feeds and ldap_views are all designed to let you run queries like this at any time. you shouldn't have to write the query yourself (but more power to you if you can).
    – tenken
    Commented Feb 21, 2014 at 18:00
  • If you need confidential info removed from a question, you need to flag the question for mod attention. Editing it will not make the info go away.
    – Letharion
    Commented Oct 20, 2014 at 13:51

1 Answer 1

2

So I assume that you are using the LDAP module?

I've not looked into the code they use however I would expect that they will close the connection before your module runs, and even if they don't the connection won't be a global variable so your module will not have access to it.

If you are writing a custom module then you do have access to the DB - just use db_query and fetch the results, or look in your settings file for your connection details. Then you can connect directly to your DB using software like Navicat.

The table ldap_servers has a field called address. This is where you will find the address to your ldap server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.