LogonUser

ActiveX/VBSScript registry editor  ActiveX NT User account manager  Export MDB/DBF from ASP
Url replacer, IIS url rewrite Active LogFile  Email export  ActiveX/ASP Scripting Dictionary object
 IISTracer, real-time IIS monitor
 Huge ASP upload - upload files with progress.
          Method 
          Member of  UserManager.Server 

Description

Attempts to perform a user logon operation and impersonates a user. You specify the user with a user name and domain, and authenticate the user with a clear-text password.

Syntax

Server.LogonUser (UserName as String, Password as String, [Domain as String = local computer], [LogonType as LogonTypes = ltInteractive])
 
Where Type Optional Default Description
 UserName  String      
 Password  String      
 Domain  String  yes  local computer   
 LogonType  LogonTypes  yes  ltInteractive   

Remarks

      WWW service is usually running under account with guest privileges. But only members of the Administrators or Account Operators group can successfully use some of User, Users, Group and Groups object methods and properties. You can logon to the Administrator account or other account by LogonUser method in ASP page .

      Remember that there are at least three conditions to succefully run LogonUser method :

1. Right UserName, Password and Domain. UserManager raises error when one of them is bad.

UserManager.Server error '8004052e' , Logon failure: unknown user name or bad password.

2. 'Logon locally' (or 'Access this computer from network') right for the user, that is logging on. When the user does not have the right, Usermanager raises this Error :

UserManager.Server error '80040569', Logon failure: the user has not been granted the requested logon type at this computer.

3. 'Act as a part of operating system' for user, in which context is running the process (probably IWAM_... user in isolated ASP process).

Error without the right : UserManager.Server error '80040522' A required privilege is not held by the client.

You can get the context account by the next code:
Dim S

Set S = CreateObject("UserManager.Server")
Wscript.Echo "Current user:" & S.LoggedOnUser

S.RevertToSelf
Wscript.Echo "Context:" & S.LoggedOnUser
You must restart computer to apply 'Act as a part of operating system' right if you have Windows 2000.

Examples

 LogonUser sample  
Dim Server, User

Set Server = CreateObject("UserManager.Server")

Server.LogonUser "Administrator", ""
'Create a new user
Set User = Server.Users.Add("NewUser", "UserPassword")
'Add the new user to the group
User.AddToLocalGroup "Guests"
'Logon new user
Server.LogonUser "NewUser", "UserPassword"
'Some other operations under new user account

Server.RevertToSelf
  Other links for LogonUser

Properties of Server class

UserManager.Server

Properties of servers, enumerating users, logon/logoff to the user administrator account.

UserManager

Easy to use classes to create, delete and manage local and remote user accounts, groups, servers and domains in the Windows NT (2000/XP) environment. Simple work with user accounts and groups from VBA, VBS/JS, ASP and T-SQL.

© 1996 – 2006 Antonin Foller, Motobit Software, help{at}pstruh.cz, help v. 2.03.68