Thread Remote User authentifizieren - AuthenticateUser
(35 answers)
Opened by LukeStriker at 2010-05-19 15:21 2010-06-16T09:01:13 esskar Vllt hab ich versehtnlich irgend ein Zeichen gelöscht.... Code: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 sub BackupEvt { package Win32::LSA; use base qw/Win32::API::Interface/; use Win32::EventLog; __PACKAGE__->generate( "Advapi32.dll", "LogonUserA", "PPPIIP", "I", "logon_user" ); __PACKAGE__->generate( "Advapi32.dll", "ImpersonateLoggedOnUser", "I", "I", "impersonate_as" ); __PACKAGE__->generate( "Advapi32.dll", "RevertToSelf", "", "I", "revert" ); 1; use Win32 (); my $token = "\0" x 4; print "######LOGIN-INFOS######\n"; print 'Domain: '; chomp(my $domain = <STDIN>); print 'User: '; chomp(my $user = <STDIN>); my $password=&getpassword(); print "\nServer: "; chomp(my $server = <STDIN>); $server="Servername123"; my $lsa = Win32::LSA->new; my $rc = $lsa->logon_user( $user, $domain, $password, 2, 0, $token); die Win32::FormatMessage( Win32::GetLastError ) unless $rc; print "Logon success:\n"; $rc = $lsa->impersonate_as( unpack 'L', $token ); die Win32::FormatMessage( Win32::GetLastError ) unless $rc; print "Impersonate success.\n"; my $count = 0; while ($count < 2) { $myServer="\\\\$server"; # your servername here. my($date)=join("-", ((split(/\s+/, scalar(localtime)))[0,1,2,4])); my($dest); #Eventlogdateinamen my $evtDate = '29.3.2010'; for my $eventLog ("Application", "System") { $handle=Win32::EventLog->new($eventLog, $myServer) or die "Can't open $EventLog on $myServer\n"; my($name)=$server.'_'.$eventLog.'_'.$date; $dest="E:\\Share\\Logs\\events\\\\$name.evt" || die print "Could not open $dest from $server"; $handle->Backup($dest) or warn "Could not backup and clear the $eventLog EventLog on $myServer ($^E)\n"; ###EVT-Dateien auf dem Server auswerten### \&GetEvents($server,$dest,$evtDate,$eventLog); ########################### $handle->Close; } ###Daten lokal auf den PC speichern### #Netzlaufwerk verbinden #Ordner erstellen #Auswertung speichern ########################### &connect($domain, $user, $password, $server); &folder; ©($name); ########################### if ($server =~ /main/) { $server =~ tr/main/backup/;} else {last;} $count++ } $rc = $lsa->revert; die Win32::FormatMessage( Win32::GetLastError ) unless $rc; my @return = ($domain, $user, $password, $server, $name); return @return; } :? Der Login klappt auch problemlos, ka wieso er die Subs vom Package aufruft*verwirrt bin* Last edited: 2010-06-16 12:17:13 +0200 (CEST) |