From: Chris R. <chr...@me...> - 2002-01-08 10:33:01
|
Philip Lembo <pl...@ar...> wrote: > I hope you'll all excuse what's probably a really basic error on my part, > but I'm having trouble with any search filter that includes givenName or > commonName as a term. Both these attribs are indexed sub, eq and pres. > We're using Netscape Directory 4.12 here. > > My script loops through a .csv file which includes the First and Last Name > of a user on each line. What I'm trying to do is match against either > First AND Last Name or Full Name (cn) on the Directory. It does work if I > only include the Last Name (although the result of such a search is > pretty much useless for my purposes). > > Here's my code (excuse the poor programming style, Until a year ago I was > just an NT desktop guy -- better to be embaressed than to continue in > ignorance though): > > use strict; > use Net::LDAP; > use Text::ParseWords; > > # Global variables for bind > my $host = 'ldap.arrow.com'; > my $ldap = new Net::LDAP($host); > my $mesg = $ldap->bind('cn=Directory Manager', password=> 'xxxxxxx'); > die ("failed to bind with ",$mesg->code(),"\n") if $mesg->code(); > > # Open the data files > open INFILE, '<users.csv' or die $!; > open OUTFILE, '>users-uid.csv' or die $!; > > # Print a header in the outfile > print OUTFILE "LanId,LName,FName,Guid,Email\n"; > > # Parse infile, format: LanId, LName, FName > while (<INFILE>) { > chomp; > my ($LanId, > $LName, > $FName > ) > = ( &parse_line(',',0,$_)); > > my $CName = "$FName $LName"; > > # Set up search variables > my $attrs = "uid,sn,givenname,mail,cn"; Ah, that should be: my $attrs = ["uid", "sn", "givenname", "mail", "cn"] because the attr argument to search takes a reference to a list as the parameter. (Which is what the [ and ] construct.) As it stands, you're asking the server to return a single attribute called "uid,sn,givenname,mail,cn", which probably won't exist. What result code is returned from the searches, and how many results come back from each one? Cheers, Chris |