|
# requires dsquery tool available with windows XP and windows 2003 resource kit
$domain = "somedomain";
$username = "someuser";
if ( ValidUser($domain,$username) )
{
print "$domain$username is a VALID user\n";
}
else
{
print "$domain$username is an invalid user\n";
}
sub ValidUser()
{
# parameter 1 = domain
# parameter 2 = username
my $domain = shift;
my $username = shift;
my $bValidUser = 0;
my $query = "dsquery user dc=$domain,dc=example, dc=com -samid $username";
print "Running $query\n";
open(CMD,"dsquery user dc=$domain,dc=main,dc=ntu,dc=edu,dc=sg -samid $username | ");
while()
{
if (/CN[=].*/g)
{
$bValidUser = 1;
}
}
close(CMD);
return $bValidUser;
}
|
|