Impersonating a User

Sometimes a script needs to log on as a different user—what is known as impersonation. Consider a Web CGI script that enables a user to modify her user account information (such as her full name) or to make modifications to her home directory. The script could accept the user’s userid and password as input parameters and attempt to log on as that user. If successful, the script could have access to files and directories to which only she has permission. Services use this feature quite often, such as Web servers and Telnet daemons.

The Win32::AdminMisc extension provides an impersonation function called LogonAsUser():

Win32::AdminMisc::LogonAsUser( $Domain, $User, $Password[, $LogonType ] ); 

The parameters for the LogonAsUser() ...

Get Win32 Perl Programming: The Standard Extensions, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.