Hej!
Har ett problem med ett script, det är såhär att genom detta scriptet ska man kunna lägga till ett konto i windows.
Har installerat perms och lanman.
Jag får inte äns igång scriptet, och det ska fungera...
#!/usr/bin/perl
# Application to log user shit into a plain textfile.
use Win32::Lanman; # for account creation
use Win32::Perms; # to set the permissions on the home directory
$homeNTdirs = "C://Documents and Settings//"; # home directory root dir, adapt to your system
sub CreateNTAccount{
#my $result = 0;
my ($account,$record) = @accarray;#@_;
# create this account on the local machine
# (i.e. empty first parameter)
$result = Win32::Lanman::NetUserAdd("",
{'name' => $account,
'password' => $record->{password},
'home_dir' => "$homeNTdirs\\$account",
'full_name' => $record->{fullname}});
return Win32::Lanman::GetLastError() unless ($result);
# add to appropriate LOCAL group (first get the SID of the account)
# we assume the group name is the same as the account type
die "SID lookup error: ".Win32::Lanman::GetLastError()."\n" unless
(Win32::Lanman::LsaLookupNames("", [$account], \@info));
$result = Win32::Lanman::NetLocalGroupAddMember("",$record->{type},
${$info[0]}{sid});
return Win32::Lanman::GetLastError() unless ($result);
# create home directory
mkdir "$homeNTdirs\\$account",0777 or
return "Unable to make homedir:$!";
# now set the ACL and owner of the directory
$acl = new Win32::Perms("$homeNTdirs\\$account");
$acl->Owner($account);
# we give the user full control of the directory and all of the
# files that will be created within it (hence the two separate calls)
$acl->Allow($account, FULL, DIRECTORY|CONTAINER_INHERIT_ACE);
$acl->Allow($account, FULL,
FILE|OBJECT_INHERIT_ACE|INHERIT_ONLY_ACE);
$result = $acl->Set();
$acl->Close();
return($result ? "" : $result);
}
CreateNTAccount;