I am trying to write a little subroutine that will take a username search and then search an Organizational Unit on a Windows 2003 AD Domain and return if the user exist or if he does not.

I tried the following snippet guessing that the Create call would fail if the user already exists, but that does not seem to be the case. Can any of you guy’s tell me or guide me in the direction where I can find an efficient way to do this. Any help would be much appreciated.

Thank you,

David

 

use Win32::OLE;

my $ADsPath = "LDAP://ou=ouname,dc=my,dc=domain";

my $connect = Win32::OLE-> GetObject($ADsPath);

my $username = 'usernamel';

 

if (my $user = $connect->Create("User", "$username"){

print "User does not exist!!\n";

}else{

  print "User exists!!\n";

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to