Have you tried using the net-ldap module? It does this pretty easily.
[EMAIL PROTECTED] wrote:
> Help! I've been banging my head against the wall on this for a while
> now. I'm trying to write a script to search for a specific user acct.
> The only piece of information I will have is logonid/samaccountname.
>
> I've been trying simple LDAP searches, but not having much luck. The
> following works, provided I already know the users name, which is
> usually the same as his Display Name. Unfortunately I won't know this,
> only thier logon id.
>
> use Win32::OLE;
> $user=Win32::OLE->GetObject("<LDAP://cn=someuser,DC=mydomain,DC=org>");
> print "$user->{'displayname'}, \n";
> print "$user->{'description'}, \n";
>
> Is there any way to apply some type of filter like
> &(objectCategory=user)(objectClass=user)(samaccountname=bubslg) to this
> query? Or is there a better way to query for an object that matches a
> specific logonid.samaccountname?
>
> Any ideas would be greatly appreciated.