Hi, On Thursday, 27. July 2006 17:53, Luis Cerezo wrote: > i am having a bit of trouble trying to get this right. > > I have a list of uids:full names that i need to match in ldap. I want to > search the Full Name if the uid does not match. (not all will.) > > while (<FH1>) { > @map = split(/:/,$_); > chomp(); > $mesg = $ldap->search ( > filter=>"(sAMAccountName=$map[0])", > base=>"blah blah", > attrs=> ['mail', 'cn', 'distinguishedName'], ); > > something here... if the sAMAccountName returns no matches (successful > bind) then try the displayName,(FULL NAME) > > # || $mesg = $ldap->search ( > filter=>"(displayName=$map[1])", > #base=>"blah blah", > #attrs=> ['mail', 'cn', 'distinguishedName'], > #); > $mesg->count or warn > "$map[0]\|$map[4]\|no_matches\n"; > @entries = $mesg->entries; > foreach $entry (@entries) { > @attrs = > $entry->attributes(); > $stuff = > $entry->get_value(mail); > $dn = > $entry->get_value(distinguishedName); > print OUT, > "stuff about blah blah and things"; > }
the search() method always returns a message object. I order to check whether the search was successful, you need to check the return code which is available using the code() method of the resulting message object. In your case e.g. if (($mesg->code != LDAP_SUCCESS) || ($mesg->count() != 1)) { # .. do whatever you want here .. } Hop it helps Peter -- Peter Marschall [EMAIL PROTECTED]