Platform SDK: Active Directory, ADSI, and Directory Services |
The IADsUser interface is designed for representing and managing an end-user account on a network. You can call the methods on this interface to access and manipulate the information about an end-user account. Such information includes names of the user, telephone numbers, job title, and so on. This interface also supports the functionality 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 line of code.
GetObject("WinNT://MYDOMAIN/jsmith,user")
Similarly, use the computer name as part of the AdsPath to bind to a local user:
GetObject("WinNT://MYCOMPUTER/jsmith,user")
In Active Directory™, domain users reside in the directory. The following line of code shows how to bind to a domain user through an LDAP provider:
GetObject("LDAP://CN=John Smith,OU=Sales,DC=Microsoft,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 fragment.
IADsUser is a dual interface that inherits from IADs. The IADsUser interface exposes the following properties and methods.
IUnknown methods | Description |
---|---|
QueryInterface | Returns pointers to supported interfaces. |
AddRef | Increments reference count. |
Release | Decrements reference count. |
IDispatch methods | Description |
---|---|
GetTypeInfoCount | Gets the number of type descriptions. |
GetTypeInfo | Gets a description of object's programmable interface. |
GetIDsOfNames | Maps name of method or property to DISPID. |
Invoke | Calls one of the object's methods, or gets and sets one of its properties. |
IADsUser properties and methods | Description |
---|---|
Get_BadLoginAddress | Gets the address of the last node, considered an "Intruder". |
Get_BadLoginCount | Gets the number of the bad logon attempts since last reset. |
Get_LastLogin | Gets the date and time of the last network login. |
Get_LastLogoff | Gets the date and time of the last network logoff. |
Get_LastFailedLogin | Gets the date and time of the last failed network login. |
Get_PasswordLastChanged | Gets the date and time of the last password change. |
Get/put_Description | Gets and sets the description of the user account. |
Get/put_Division | Gets and sets the division within a company (organization). |
Get/put_Department | Gets and sets the organizational unit within the organization. |
Get/put_EmployeeID | Gets and sets employee identification number of the user. |
Get/put_FullName | Gets and sets the full name of the user. |
Get/put_FirstName | Gets and sets the first name of the user. |
Get/put_LastName | Gets and sets the last name of the user. |
Get/put_OtherName | Gets and sets the additional name, such as the nickname, or the middle name of the user. |
Get/put_NamePrefix | Gets and sets the name prefix, such as Mr. Ms., or Hon., of the user |
Get/put_NameSuffix | Gets and sets the name suffix (Jr., III) of the user. |
Get/put_Title | Gets and sets the user's title within the organization. |
Get/put_Manager | Gets and sets the manager of the the user. |
Get/put_TelephoneHome | Gets and sets the list of home phone numbers of the user. In Active Directory the list has a single element. |
Get/put_TelephoneMobile | Gets and sets the list of mobile phone numbers of the user. In Active Directory the list has a single element. |
Get/put_TelephoneNumber | Gets and sets the list of work-related phone numbers. In Active Directory the list has a single element. |
Get/put_TelephonePager | Gets and sets the list of pager phone numbers. |
Get/put_FaxNumber | Gets and sets the list of fax phone numbers. In Active Directory the list has a single element. |
Get/put_OfficeLocations | Gets and sets the array of end-user locations. In Active Directory the array has a single element. |
Get/put_PostalAddresses | Gets and sets the array of end-user post office addresses. |
Get/put_PostalCodes | Gets and sets the array of zip codes for the Postal Addresses. In Active Directory the array has a single element. |
Get/put_SeeAlso | Gets and sets the array of ADsPaths of other objects related to this user. |
Get/put_AccountDisabled | Gets and sets the flag to indicate whether or not the account is disabled. |
Get/put_AccountExpirationDate | Gets and sets the expiration date and time of the user. |
Get/put_GraceLoginsAllowed | Gets and sets the number of times user can log on after password has expired. |
Get/put_GraceLoginsRemaining | Gets and sets the number of grace logins left before locking account. |
Get/put_IsAccountLocked | Gets and sets a flag to indicate whether or not an account is locked. |
Get/put_LoginHours | Gets and sets the time periods during each day of week indicating valid login periods. |
Get/put_LoginWorkstations | Gets and set the workstations and their net addresses for this end-user. |
Get/put_MaxLogins | Gets and sets the maximum number of simultaneous logins. |
Get/put_MaxStorage | Gets and set the maximum amount of disk space allowed for the user. |
Get/put_PasswordExpirationDate | Gets and sets the date and time when password will expire. |
Get/put_PasswordMinimumLength | Gets and sets the minimum number of characters allowed in a password. |
Get/put_PasswordRequired | Gets and sets a flag to indicate whether or not a password is required. |
Get/put_RequireUniquePassword | Gets and sets a flag to indicate whether or not a new password must be different from ones in the password history list. |
Get/put_EmailAddress | Gets and sets the email address of the user. |
Get/put_HomeDirectory | Gets and sets the home directory of the user. |
Get/put_Languages | Gets and sets the array of language names for the end-user. |
Get/put_Profile | Gets and sets the end-user's profile path. |
Get/put_LoginScript | Gets and sets the end-user's login script path. |
Get/put_Picture | Gets and sets the picture of the user. |
Get/put_HomePage | Gets and sets the URL to the home page of the user. |
Groups | Determines the groups to which this end-user belongs. |
SetPassword | Sets the password. |
ChangePassword | Changes password from the specified existing value to a new value. |
As with any other ADSI object, the container object creates a Windows NT®/Windows® 2000 user account object. This means you need to bind to a container object first. Then call the IADsContainer::Create method and specify all mandatory or optional attributes.
User Creation Using WinNT
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.
Set dom = GetObject("WinNT://aDomain") Set usr = dom.Create("user","jsmith") usr.SetInfo
In this case, a domain user is created with the following default attribute values:
Property | Value |
---|---|
Full Name | SAM Account Name (such as jsmith) |
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 machine, as shown in the following code snippet:
Set mach = GetObject("WinNT://aMachine,Computer") Set usr = mach.Create("user","jsmith") usr.SetInfo
The newly created local user will have the same default properties as the domain user discussed earlier. The group membership, however, will be "users", instead of "domain user".
Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with DSClient).
Windows 95/98: Requires Windows 95 or later (with DSClient).
Header: Declared in Iads.h.