Posted by humansky on May 15, 2012 at 7:58pm
Hello,
I wrote a custom Drupal 7 module and I would love to utilize the LdapQuery() class but I'm running into a few issues. Is there anyway to use that class without having to go through the GUI? Here is my current code:
global $user;
$ldap_query = new LdapQuery('ldap_query_user');
$ldap_query->filter = '(uid=' . $user->name . ')';
$ldap_result = $ldap_query->query();And this works fine, except I want to be able to recreate "'ldap_query_user" in my module and not have to create it through Drupal's LDAP Admin GUI. Is this possible? Does anyone have sample code?
Thank you,
Henry

Comments
something like this should work, but I've never done this
include ldap_query/LdapQueryAdmin.class.php,
then...
$ldap_query = new LdapQueryAdmin();
$ldap_query->qid = 'qod';
$ldap_query->name = 'Query of the day';
$ldap_query->sid = 'blah';
$ldap_query->status = 1;
$ldap_query->inDatabase = 0; // this means its a new one or create
... with all the public properties in ldapquery.class.php....
$ldap_query->save(); // will save it to the db
www.johnbarclay.com
I see, so then I
I see, so then I switch:
$ldap_query = new LdapQuery('ldap_query_user');
to:
$ldap_query = new LdapQuery('qod'); //or whatever machine name I choose
Also, do you see a huge performance hit if I don't save this to the database, instead instantiate the class every time the page is rendered? The page I plan to use this query will be password protected and not used too often.
Will be faster outside the database than in it.
Can you add whatever works for you to the LDAP Query documentation at: http://drupal.org/node/1302080 ?
Maybe something like "Developer Notes" near the bottom of the page.
www.johnbarclay.com