From: Sean <mb...@ba...> - 2002-08-15 20:14:37
|
Hello. I have a problem with a script I'm using to query an ldap server. = Unfortunately I have to have this script done by tonight so I'm a but rushed and need some help. The script should always bring back only one entry, but I will be = checking that anyway. Once it comes back I want to pull out 4 = attributes and set variables to the contents of those attributes for = future work. When I run the script it shows that one record is returned. However I'm = not getting the contents of the attribute correctly. Here's the script: #!/usr/local/bin/perl use CGI; use Net::LDAP qw(:all); # Use the perl-ldap module # Query ldap server for student information $ldap =3D Net::LDAP->new('148.8.60.60') or die "$@"; $ldap->bind; # Connect anonymous to server $attrs =3D ['EmployeeID','userBirthDate','sn','uid' ]; my $QUERYRESULT =3D $ldap->search ( base =3D> "o=3Dstuorg", scope =3D> "sub", filter =3D> "uid=3Dappletor", attrs =3D> $attrs ); my $QUERYCOUNT =3D $QUERYRESULT->count; print $QUERYCOUNT; # Verify only one record returned if ($QUERYCOUNT eq "0") { print "query returned no records"; exit (0); } # Set query result to first record in array. my $QUERYRESULTENTRY =3D $QUERYRESULT->entry(0); # PUll information from ldap record and populate local variables my $QUERYLASTNAME =3D $QUERYRESULTENTRY->get( 'sn' ); print $QUERYLASTNAME; The results are: hawk:/tmp # ./test.pl 1ARRAY(0x2f5c80) Thanks! Sean O'Brien Sr. Unix Engineer AE Business Solutions |