使用JXplorer浏览我们的AD服务器时,我可以查看每个用户的表,其中包含所有信息的key = value对。我正在搜索的主要属性之一,无论是在JXplorer中,还是希望在Perl中,都是badPasswordTime属性。
示例用户</ p>
cn Doe, Johnathon (ETW) badPasswordTime 130517418896803805 sAMAccountName jdoe43
这是我用来搜索特定用户的Perl。此脚本功能齐全,但已删除了一些数据。这里的问题是,当我转储从Perl检索到的整个记录时,会丢失很多信息。我试图找到的一个特定信息是上面提到的属性badPasswordTime,这是他们密码在AD风格中的到期日期。
#!/usr/bin/perl
use strict;
use warnings;
use Net::LDAP;
my $password = '<password>';
my $server = "<ldap.svr>";
my $user = 'Doe, John';
my $ldap = Net::LDAP->new( $server ) or die $@; $ldap->bind( password => $password );
my $result = $ldap->search( base => "OU=All Users,DC=ad,DC=<co>,DC=com", filter => "(&(cn=$user*) )",); die $result->error if $result->code;
foreach my $entry ($result->entries){ print $entry->dump; }
$ldap->unbind;
exit 0;
以下是脚本从转储中返回的示例:
dn:CN=Doe\, John (ETW),OU=All Users,DC=ad,DC=,DC=com objectClass: top person organizationalPerson user cn: Doe, John (ETW) sn: Doe title: Application Developer telephoneNumber: 503-555-0125 givenName: John distinguishedName: CN=Doe\, John (ETW),OU=All Users,DC=ad,DC=,DC=com displayName: Doe, John (ETW) co: United States department: DT_Tech Operations name: Doe, John (ETW) sAMAccountName: jdoe43 userPrincipalName: jdoe43@.com mail: John.Doe@.com manager: CN=Smith\, Jane,OU=All Users,DC=ad,DC=,DC=com
<小时/> 当在资源管理器中清楚地看到属性时,为什么不返回该属性?
** UDPATE **
使用CLT ldapsearch时使用以下命令:
ldapsearch -x -LLL -h ldap.co.com -z 1 -D "CN=,OU=All Users,DC=ad,DC=co,DC=com" -w -b "OU=All Users,DC=ad,DC=co,DC=com" -s sub "(displayName=Smith, Jane)" badPasswordTime
返回:
dn: CN=Smith\, Jane,OU=All Users,DC=ad,DC=co,DC=com badPasswordTime: 130529531762460841