O'Reilly logo

Win32 Perl Programming: The Standard Extensions, Second Edition by Dave Roth

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required