I'm working on an API for the Koozali SME Server to use Samba 4, Active
Directory.   One of the things I'm trying to do is abstract quite alot of
the Net::LDAP syntax so that SME Server admins can just ask the API for
various pieces of data from the active directory and the API will return
them.

I've spent the last couple months working on this and have a pretty good
set of methods to provide the functions we need.

One things I'm not doing a very good job at is unbinding from the active
directory (LDAP).  As I go back through my code, I'm running into a problem
where my class is essentially hiding the Net::LDAP object, so I'm not sure
how to unbind.

Here's the scenario.   I have a method that binds to the active directory
called "connect()" and returns an Net::LDAP object.  I then have another
method that does the queries I need and returns a Net::LDAP::Search object
called "query()."  query() calls the connect() method so that a user can
simply do this:

use esmith::AD;  #my class

$ad = esmith:AD->new();

@users = $ad->query(#some query parameters);

Problem is, once I return from the query() method, its seems I've lost the
Net::LDAP object, so I can't unbind.

One solution would be to not call the "connect()" method in my "query()"
method, but instead pass it as a parameter so that the calling method never
loses it.  The problem with this is that I would then seem to be repeating
alot of code over and over in each my methods.  Another option would be to
cache the connection in the class as key to the anonymous hash reference
for the class.

I hope this makes sense.  I tried to include enough detail, while not
having to paste in my entire 800 line perl module.

Thanks!

Greg Zartman

Reply via email to