IADsUser interface
The IADsUser interface is a dual interface that inherits from IADs. It is designed to represent and manage an end-user account on a network. Call the methods of this interface to access and manipulate end-user account data. Such data includes names of the user, telephone numbers, job title, and so on. This interface supports features for determining the group association of the user, and for setting or changing the password.
To bind to a domain user through a WinNT provider, use the domain name as part of the ADsPath, as shown in the following code example.
GetObject("WinNT://MYDOMAIN/jeffsmith,user")
Similarly, use the computer name as part of the ADsPath to bind to a local user.
GetObject("WinNT://MYCOMPUTER/jeffsmith,user")
In Active Directory, domain users reside in the directory. The following code example shows how to bind to a domain user through an LDAP provider.
GetObject("LDAP://CN=Jeff Smith,OU=Sales,DC=Fabrikam,DC=Com")
However, local accounts reside in the local SAM database and the LDAP provider does not communicate with the local database. Thus, to bind to a local user, you must go through a WinNT provider as described in the second code example.
Members
The IADsUser interface inherits from IDispatch and IADs. IADsUser also has these types of members:
Methods
The IADsUser interface has these methods.
| Method | Description |
|---|---|
| ChangePassword |
Changes password from the specified existing value to a new value. |
| Get |
Gets the value for a property by name. |
| GetEx |
Gets the value for a single or multi-valued property by name. |
| GetInfo |
Loads the property values of this object from the underlying directory store. |
| GetInfoEx |
Loads specific property values of this object from the underlying directory store. |
| Groups |
Determines the groups to which this end-user belongs. |
| Put |
Sets the value for a property by name. |
| PutEx |
Sets the value for a single or multi-valued property by name. |
| SetInfo |
Persists the changes on this object to the underlying directory store. |
| SetPassword |
Sets the password. |
Properties
The IADsUser interface has these properties.
| Property | Access type | Description |
|---|---|---|
|
Read/write |
Gets and sets the flag to indicate whether the account is disabled. | |
|
Read/write |
Gets and sets the expiration date and time of the user. | |
|
Read-only |
Gets the object's ADsPath that uniquely identifies this object from all others. | |
|
Read-only |
Gets the address of the last node, considered an "Intruder". | |
|
Read-only |
Gets the number of the bad logon attempts since last reset. | |
|
Read-only |
Gets the name of the object's schema class. | |
|
Read/write |
Gets and sets the organizational unit within the organization. | |
|
Read/write |
Gets and sets the description of the user account. | |
|
Read/write |
Gets and sets the division within a company (organization). | |
|
Read/write |
Gets and sets the email address of the user. | |
|
Read/write |
Gets and sets employee identification number of the user. | |
|
Read/write |
Gets and sets the list of fax phone numbers. In Active Directory the list has a single element. | |
|
Read/write |
Gets and sets the first name of the user. | |
|
Read/write |
Gets and sets the full name of the user. | |
|
Read/write |
Gets and sets the number of times user can log on after password has expired. | |
|
Read/write |
Gets and sets the number of grace logins left before locking account. | |
|
Read-only |
Gets the GUID of the object as stored in the underlying directory store. | |
|
Read/write |
Gets and sets the home directory of the user. | |
|
Read/write |
Gets and sets the URL to the home page of the user. | |
|
Read/write |
Gets and sets a flag to indicate whether an account is locked. | |
|
Read/write |
Gets and sets the array of language names for the end-user. | |
|
Read-only |
Gets the date and time of the last failed network login. | |
|
Read-only |
Gets the date and time of the last network login. | |
|
Read-only |
Gets the date and time of the last network logoff. | |
|
Read/write |
Gets and sets the last name of the user. | |
|
Read/write |
Gets and sets the time periods during each day of week that indicate valid login periods. | |
|
Read/write |
Gets and sets the end-user's login script path. | |
|
Read/write |
Gets and set the workstations and their net addresses for this end-user. | |
|
Read/write |
Gets and sets the manager of the user. | |
|
Read/write |
Gets and sets the maximum number of simultaneous logins. | |
|
Read/write |
Gets and set the maximum amount of disk space allotted for the user. | |
|
Read-only |
Gets the object's relative name. | |
|
Read/write |
Gets and sets the name prefix, such as Mr., Ms., or Hon., of the user. | |
|
Read/write |
Gets and sets the name suffix, such as Jr. or III, of the user. | |
|
Read/write |
Gets and sets the array of end-user locations. In Active Directory the array has a single element. | |
|
Read/write |
Gets and sets the additional name, such as the nickname, or the middle name of the user. | |
|
Read-only |
Gets the ADsPath string for the parent of the object. | |
|
Read/write |
Gets and sets the date and time when password expires. | |
|
Read-only |
Gets the date and time of the last password change. | |
|
Read/write |
Gets and sets the minimum number of characters allowed in a password. | |
|
Read/write |
Gets and sets a flag to indicate whether a password is required. | |
|
Read/write |
Gets and sets the picture of the user. | |
|
Read/write |
Gets and sets the array of end-user post office addresses. | |
|
Read/write |
Gets and sets the array of postal codes for the Postal Addresses. In Active Directory the array has a single element. | |
|
Read/write |
Gets and sets the end-user's profile path. | |
|
Read/write |
Gets and sets a flag to indicate whether a new password must be different from ones in the password history list. | |
|
Read-only |
Gets the ADsPath string to the schema class object for this object. | |
|
Read/write |
Gets and sets the array of ADsPaths of other objects related to this user. | |
|
Read/write |
Gets and sets the list of home phone numbers of the user. In Active Directory the list has a single element. | |
|
Read/write |
Gets and sets the list of mobile phone numbers of the user. In Active Directory the list has a single element. | |
|
Read/write |
Gets and sets the list of work-related phone numbers. In Active Directory the list has a single element. | |
|
Read/write |
Gets and sets the list of pager phone numbers. | |
|
Read/write |
Gets and sets the user's title within the organization. |
Remarks
As with any other ADSI object, the container object creates a Windows user account object. First, bind to a container object. Then, call the IADsContainer::Create method and specify mandatory or optional attributes.
With WinNT, you do not have to specify any additional attributes when creating a user. You may call the IADsContainer::Create method to create the user object directly.
Dim dom As IADsContainer Dim usr As IADsUser On Error GoTo Cleanup Set dom = GetObject("WinNT://MyDomain") Set usr = dom.Create("user","jeffsmith") usr.SetInfo Cleanup: If(Err.Number<>0) Then MsgBox("An error has occurred. " & Err.Number) End If Set mach = Nothing Set usr = Nothing
In this case, a domain user is created with the following default values.
| Property | Value |
|---|---|
|
Full Name |
SAM Account Name (such as jeffsmith) |
|
Password |
Empty |
|
User Must Change Password |
TRUE |
|
User Cannot Change Password |
FALSE |
|
Password Never Expires |
FALSE |
|
Account Disabled |
FALSE |
|
Group |
Domain User |
|
Profile |
Empty |
|
Account Never Expires |
TRUE |
To create a local user, bind to a target computer, as shown in the following code example.
Dim mach As IADsContainer Dim usr as IADsUser On Error GoTo Cleanup Set mach = GetObject("WinNT://MyMachine,Computer") Set usr = mach.Create("user","jeffsmith") usr.SetInfo Cleanup: If(Err.Number<>0) Then MsgBox("An error has occurred. " & Err.Number) End If Set mach = Nothing Set usr = Nothing
The newly created local user will have the same default properties as the domain user. The group membership, however, will be "users", instead of "domain user".
Requirements
|
Minimum supported client |
Windows Vista |
|---|---|
|
Minimum supported server |
Windows Server 2008 |
|
Header |
|
|
DLL |
|
|
IID |
IID_IADsUser is defined as 3E37E320-17E2-11CF-ABC4-02608C9E7553 |
See also