Thread Remote User authentifizieren - AuthenticateUser (35 answers)
Opened by LukeStriker at 2010-05-19 15:21

esskar
 2010-05-19 16:51
#137352 #137352
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
versuch es mal mit diesem ansatz: (hab es von mir rauskopiert)
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
#!/usr/bin/perl

use strict;
use warnings;

package Win32::LSA;
use base qw/Win32::API::Interface/;

__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;
my $lsa = Win32::LSA->new;
my $rc = $lsa->logon_user( $ENV{USER}, $ENV{DOMAIN}, $ENV{PASS}, 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";

# hier dein code 

$rc = $lsa->revert;
die Win32::FormatMessage( Win32::GetLastError ) unless $rc;


PS: wenn es ein modul nicht (mehr) auf CPAN gibt, hat es oft grĂ¼nde.

EDIT: codeverbesserung.
Last edited: 2010-05-20 11:56:36 +0200 (CEST)

View full thread Remote User authentifizieren - AuthenticateUser