#test for Perl NetAdmin Module Extension.
#Written by Douglas Lankshear for hip communications.



BEGIN{
    @INC = qw( ../lib );

        if( Win32::IsWin95() ){
        	print"1..1\nok 1\n";
	        die" This module does not work on Win95\n";
	}
	($string, $major, $minor, $build, $id) = NTGetOSVersion;
	if( $major == 3 && $minor < 51){
		print"1..1\nok 1\n";
	        die" This module requires NT 3.51 or later\n";
	}

};

use Win32::NetAdmin;

$userName = 'TestUser';
$password = '';
$passwordAge = 0;
$privilege = USER_PRIV_USER;
$homeDir = 'c:\\';
$comment = 'This is a test user';
$flags = UF_SCRIPT;
$scriptpath = 'C:\\';
$groupName = 'TestGroup';
$groupComment = "This is a test group";

print "1..16\n";

Win32::NetAdmin::UserCreate('', $userName, $password, $passwordAge, $privilege, $homeDir, $comment, $flags, $scriptpath) || print "not ";
print "ok 1\n";

Win32::NetAdmin::UserGetAttributes('', $userName, $Getpassword, $GetpasswordAge, $Getprivilege, $GethomeDir, $Getcomment, $Getflags, $Getscriptpath) || print "not ";
print "ok 2\n";

($password eq $Getpassword) || print "not ";
print "ok 3\n";

($passwordAge == $GetpasswordAge) || print "not ";
print "ok 4\n";

# privilege is always returned as 0
#($privilege == $Getprivilege) || print "not ";
($Getprivilege == 0) || print "not ";
print "ok 5\n";

($homeDir eq $GethomeDir) || print "not ";
print "ok 6\n";

($comment eq $Getcomment) || print "not ";
print "ok 7\n";

($flags == ($Getflags&USER_PRIV_MASK)) || print "not ";
print "ok 8\n";

($scriptpath eq $scriptpath) || print "not ";
print "ok 9\n";

Win32::NetAdmin::LocalGroupCreate('', $groupName, $groupComment) || print "not ";
print "ok 10\n";

Win32::NetAdmin::LocalGroupGetAttributes('', $groupName, $GetgroupComment) || print "not ";
print "ok 11\n";

($groupComment eq $GetgroupComment) || print "not ";
print "ok 12\n";

Win32::NetAdmin::LocalGroupAddUsers($domainName, $groupName, $userName) || print "not ";
print "ok 13\n";

Win32::NetAdmin::LocalGroupIsMember('', $groupName, $userName) || print "not ";
print "ok 14\n";

Win32::NetAdmin::LocalGroupDelete('', $groupName) || print "not ";
print "ok 15\n";

Win32::NetAdmin::UserDelete('', $userName) || print "not ";
print "ok 16\n";

