-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathldap.pl
32 lines (25 loc) · 923 Bytes
/
ldap.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/local/bin/perl -w
use Net::LDAP;
my $ldap = Net::LDAP->new( 'ldaps://10.204.160.10' ) or die "$@";
my $mesg = $ldap->bind( '[email protected]',
password => '3z3quiel782300='
);
my $base = "dc=tmoviles,dc=com,dc=ar";
my $attrs = [ 'cn','mail','mobile' ];
$mesg = $ldap->search ( base => "$base",
scope => "sub",
filter => "samAccountName=mgiller",
attrs => $attrs
);
print "ERROR: ".$mesg->error." MSG: ".$mesg->code."\n";
my $entry;
foreach $entry ($mesg->entries) {
print "DN=".$entry->dn()."\n";
if($entry->exists("mobile"))
{
print "OK\n";
}else{
print "No PHONE\n";
}
print "Phone: ".$entry->get_value("mobile")."\n";
}