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.
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 |
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.LoggedOnUserYou must restart computer to apply 'Act as a part of operating system' right if you have Windows 2000.
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 |
GetAnyDCName, GetDCName, ChangePassword, LogonUser, RevertToSelf, Select
Comment, ComputerName, Domain, Groups, LocalGroups, LoggedOnUser, Name, Servers, Type, Users
Properties of servers, enumerating users, logon/logoff to the user administrator account.
ActiveX UserManager is easy to use COM component with classes to create, delete and manage local and remote user accounts, groups, servers and domains in the Windows NT (2000/XP) environment. You can simple work with user accounts and groups from VBA, VBS/JS, ASP and T-SQL programming environment.
© 1996 - 2009 Antonin Foller, Motobit Software | About, Contacts | e-mail: info@pstruh.cz