From: Philip L. <pl...@ar...> - 2002-01-08 15:36:03
|
Chris: Thanks for the quick reply. I made the changes suggested, but it still doesn't seem to be working. My return code is "255" with the text message, "Failed to search with Bad filter". No results are returned, so it looks like it's failing immediately. Are there some things I should be checking on the server (other than the indexing, although can I really be sure that the indexes are really "working"?)? Phil -----Original Message----- From: Chris Ridd [mailto:chr...@me...] Sent: Tuesday, January 08, 2002 5:33 AM To: Philip Lembo; per...@li... Subject: Re: Search Filter Problem - Can't Search on cn or givenName 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 |