UserManager Object

Overview

UserManager is the main top-level object that provides a considerable portion of AspUser's functionality, as well as serves as an "object factory" for the Group, User, FileOrDir, and Server objects. In an ASP environment, UserManager can be created by the statement
<% Set AU = Server.CreateObject("Persits.AspUser") %>
or tag
<OBJECT RUNAT=SERVER PROGID="Persits.AspUser" ID=AU>
</OBJECT>
In a VB environment, the UserManager object can be created as follows (after checking the box next to "Persits Software AspUser 1.0" in the References dialog):
Dim AU As UserManager
Set AU = New UserManager

Member List

Properties


Domain As String (Read-only)
Specifies the domain on which all the "domain" commands will be executed, such as UserManager.Users or UserManager.Groups. Use this property only if you need to manage domains other that one the component in installed on. Otherwise leave this property empty.

DomainController As String (Read-only)
Returns the name of the primary domain controller for the current domain, or domain specified by the Domain property.

Expires As Date (Read-only)
Returns the date/time when the component expires. If the value is "9/9/9999" the component never expires.

Groups As IGroups (Read-only)
Returns the Groups collection of Domain groups for the current domain, or domain specified by the Domain property.

IncludeErrorCode As Boolean (Read/Write)
False by default. If set to True, all exception messages generated by AspUser will begin with the corresponding genuine NT error codes in the Hex format, e.g. "0005 Access is denied." or "08BC The user already belongs to this group."

LocalGroups As IGroups (Read-only)
Returns the Groups collection of local groups for the current server, or server specified by the Server property.

LocalUsers As IUsers (Read-only)
Returns the Users collection of local users for the current server, or server specified by the Server property.

Server As IServers (Read/Write)
Use this property to specify the server on which all the LocalXXX commands will be executed, such as UserManager.LocalUsers or UserManager.LocalGroups. The server name must begin with '\\'. Leave empty if the local machine is used.

Servers As IServers (Read-only)
Returns the Servers collection of servers visible from the current server and domain, or the server and domain specified by the Server and Domain properties, respectively.

Users As IUsers (Read-only)
Returns the Users collection of the Domain users for the current domain, or domain specified by the Domain property.

Version As String (Read-only)
Returns the current version of the component. This property was added in version 1.2.

Methods


Function AddGroup(Name As String, Comment As String) As IGroup
Adds a new domain group. Returns the Group object representing the newly created group, or Nothing if the creation failed.

Function AddLocalGroup(Name As String, Comment As String) As IGroup
Adds a new domain group. Returns the Group object representing the newly created group, or Nothing if the creation failed.

Function AddLocalUser(Name As String, Password As String, Comment As String) As IUser
Adds a new local user. Returns a User object representing the newly created user, or Nothing if the creation failed. Use the returned User object to set additional user account properties.

Function AddUser(Name As String, Password As String, Comment As String) As IUser
Adds a new domain user. Returns a User object representing the newly created user, or Nothing if the creation failed. Use the returned User object to set additional user account properties.

Sub ChangePassword(Domain As String, Username As String, OldPassword As String, NewPassword)
Changes a user’s password for a specified network server or domain. If Domain is empty, the local machine is assumed. If Username is in the format DOAMAIN\USERNAME the domain name prefix will be ignored.

Sub DeleteGroup(Name As String)
Deletes a domain group.

Sub DeleteLocalGroup(Name As String)
Deletes a local group.

Sub DeleteLocalUser(Name As String)
Deletes a local user account.

Sub DeleteUser(Name As String)
Deletes a domain user account.

Function File(Path As String) As IFileOrDir
Returns a FileOrDir object representing a NTFS file or directory. You can use this object to manipulate Access Control Lists (ACLs) and attributes of that file.

Function GetComputerName() As String
Returns the name of the current server.

Function GetDomainName() As String
Returns the current domain name, or domain name of the server specified by the Server property.

Function GetGroup(Name As String, Optional IsDomain = True) As IGroup
Returns a Group object. If IsDomain is True (default) a domain group object is returned, otherwise a local group object is returned. Unlike Groups and LocalGroups collections, this method allows you to retrieve a single group account without loading all group accounts into memory. Use this method if your NT account database contains a large number of groups.

Function GetUser(Name As String, Optional IsDomain = True) As IUser
Returns a User object. If IsDomain is True (default) a domain user object is returned, otherwise a local user object is returned. Unlike Users and LocalUsers collections, this method allows you to retrieve a single user account's information without loading all user accounts into memory. Use this method if your NT account database contains a large number of users.

Function GetUserName() As String
Returns the name of the user currently logged onto the system.

Sub LogonUser(Domain As String, Username As String, Password As String, Optional LogonType = LOGON_INTERACTIVE)
Impersonates the specified Windows NT user account. All of the following operations will be performed in the security context of this account. If Domain is empty, the local account database will be used to validate the password. The LogonType argument is optional. The possible values are: LOGON_INTERACTIVE (2), LOGON_NETWORK (3), LOGON_BATCH (4), LOGON_SERVICE (5).

Sub RevertToSelf() As String
Terminates impersonation begun by LogonUser.