From: Jim H. <ha...@us...> - 2002-04-11 21:38:28
|
I assume that you consider a duplicate entry something with the same first and last name? In the strict LDAP sense of things, there are no duplicate entries returned from a given query. I think that what you want to do is something like: %seen = (); $mesg = $ldap->search( base => "o=base", scope => "subtree", filter => "sn=*", attrs => ["givenname"] ); foreach $entry ($mesg->entries) { $given = get_value("givenname"); $sn = get_value("sn"); ++$entryct{"$sn, $givenname}; ++$entrydn{"$sn, $givenname} .= ($entry->dn . "\n"); } foreach $nameset (keys $entryct) { next unless $entryct{$nameset} > 1; print "$entrycdn{$nameset}\n"; } On Thu, 11 Apr 2002 CZa...@wi... wrote: > > I am try to detect any duplicate entries in my LDAP Service directory and > print to STDOUT or, to a file. But, I first wanted to see if it would pass > back all duplicates. > > > > > Jim Harle > <harle@usna.ed To: CZa...@wi... > u> cc: per...@li... > Subject: Re: Checking for duplicate entries > 04/11/2002 > 05:03 PM > > > > > > > Please be more precise about what you are trying to do. The code you > included works fine if I use > > $var1 = 'John'; > $var2 = 'Smith'; > > on my server, I get the 2 entries just fine. I would change > unless $seen{$entry} > to > unless $seen{$entry->dn} > but I don't think that will do anything in this case. > > Are you trying to find all sn/givenname combinationss where more than one > match? > > --Jim > > On Thu, 11 Apr 2002 CZa...@wi... wrote: > > > Hello, can anyone help on this. I am trying to display duplicate enties > > that are in > > the ldap service. > > > > %seen = (); > > $mesg = $ldap->search( > > base => "o=base", > > scope => "subtree", > > filter => "(&(givenname=$var1) (sn > =$var2))" > > ); > > > > foreach $entry ($mesg->entries) { > > printf "%s \n", $entry->dn unless $seen{$entry}++ > > } > > > > > > > > > > |