hello all,
i have daveloped a perl script to compare 1000users to a large data base of 1 lakh users,in which each the data is such that each user has login name ,description,e-mail address etc associated with him,but i am having only the names of the 1000 users ,so what my job ,is to find all the details of these 1000 users from the 1 lakh users data base,like their respective departments,emial address etc;i had written a code for it ..but what the problem is that when i run it i get the error message...uninitialized value in string concatenation i am adding my code below...can any one help me to fix it thanks in advance
#!/usr/bin/perl -w use strict; use Net::LDAP; use Data::Dumper; my $username="CN=xxxxx,OU=MUC-Users,OU=Users,OU=MUC,DC=eu,DC=xxxxxx,DC +=com"; my $password='xxxx"==('; # global data my $ad; my %users = (); #my $someotheruser =(); #my $someotheruse; #my $fulluser = (); # Collect all data from LDAP my %ldap_server = (yy => 'xxxxx.com', dd => 'lxxxxxx.com', cc => 'xxxx +xxxxxx.com'); for my $region (sort keys %ldap_server) { # we need to authenticate in each region separately $ad = Net::LDAP->new($ldap_server{$region}) or die ("Could not con +nect to LDAP server $ldap_server{$region}: $@"); print "INFO: Connected to server $ldap_server{$region}\n"; my $return = $ad->bind ($username, password=>$password) or die ("C +ould not bind to LDAP server as user $username: $@"); $return->code && die $return->error; print "INFO: Bound to server $ldap_server{$region} as user $userna +me\n"; # collect all user info in region _get_users ($region, ''); # unbind from LDAP server again $ad->unbind; } #my $i = 0; foreach (keys %users) { $i++ }; print "$i users found\ +n"; my $f =""; foreach my $user (values %users) { $f = "$user->{'sn'}" . "$user->{'givenName'}"; #print$f; my @data; # open file open(FILE, "good.txt") or die("Unable to open file"); # read file + into an array @data = <FILE>; # close fil +e close(FILE); my $e =""; foreach $e (@data) { if( $f = $e ) { print$user->{'sn'}.$user->{'givenName'}.print$user->{'descript +ion'}.$user->{'mail'}; } } } exit; sub _get_users { my ($region, $prefix) = @_; my @patternlist = qw(a b c d e f g h i j k l m n o p q r s t u v w + x y z 0 1 2 3 4 5 6 7 8 9 _ -); #my @patternlist = qw(a); for my $pattern (@patternlist) { my $return = $ad->search(base=>"DC=$region,DC=xxxxxxx,DC=com", filter=>"(&(objectCategory=user)(cn=$ +prefix$pattern*))", scope=>'sub') or die ("Could not search LDAP server: $@"); my $error = $return->code; if ($error) { if ($error == 4) { print "Sizelimit exceeded for Region $region, $prefix$ +pattern\* .. extending\n"; _get_users ($region, "$prefix$pattern"); } else { print $return->error; } } else { #print "Region $region, $prefix$pattern\*: ", $return->cou +nt, " users found\n"; } my @entries = $return->entries; foreach my $entry (@entries) { my $user = (); foreach (qw(cn sn givenName department Ihj-klDir-GlobalID +description mail I-eDjr-AccountType distinguishedName userWorkstation s)) { $user->{$_} = $entry->get_value($_); } my @array = $entry->get_value('memberOf'); $user->{'memberOf'} = \@array; $users{$entry->get_value('distinguishedName')} = $user; } } }

20071105 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips


In reply to data comparison by topman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.