IADsUser
The IADsUser interface is designed to represent and manage user accounts. Call the methods of this interface to access and manipulate 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 membership of the user, and for setting or changing the password.
Inheritance: IADs
Methods
-
Method
-
Description
-
ChangePassword()
-
Changes the user's password from the specified old value to a new value.
-
Groups()
-
Returns a collection of group objects where the user is a member.
-
SetPassword()
-
Sets the user's password to the specified value.
Properties
-
Property
-
Description
-
AccountDisabled
-
Gets or sets a value indicating whether the account is disabled.
-
AccountExpirationDate
-
Gets or sets the expiration date and time of the user account.
-
BadLoginAddress
-
Gets the address of the last node considered a possible intruder.
-
BadLoginCount
-
Gets the number of the bad logon attempts since last reset.
-
Department
-
Gets the organizational unit where the user account resides.
-
Description
-
Gets or sets the description of the user account.
-
Division
-
Gets or sets the user's division within a company.
-
EmailAddress
-
Gets or sets the email address of the user.
-
EmployeeID
-
Gets or sets the employee identification number of the user.
-
Faxnumber
-
Gets or sets the fax number of the user.
-
FirstName
-
Gets or sets the first name of the user.
-
FullName
-
Gets or sets the full name of the user.
-
GraceLoginsAllowed
-
Gets or sets the number of times the user can log on after password has expired.
-
GraceLoginsRemaining
-
Gets or sets the number of grace logins left before locking account.
-
HomeDirectory
-
Gets or sets the home directory of the user.
-
HomePage
-
Gets or sets the path to the home page of the user.
-
IsAccountLocked
-
Gets or sets a value indicating whether the user account is locked out.
-
Languages
-
Gets or sets an array of language names for the user.
-
LastFailedLogin
-
Gets the date and time of the last failed network login.
-
LastLogin
-
Gets the date and time of the last network login.
-
LastLogoff
-
Gets the date and time of the last network logoff.
-
LastName
-
Gets or sets the last name of the user.
-
LoginHours
-
Gets or sets the days of the week and time periods when logons are permitted for the user.
-
LoginScript
-
Gets or sets the user's login script path.
-
LoginWorkstations
-
Gets or sets the addresses or names of workstations from which the user can log on.
-
Manager
-
Gets or sets the distinguished name of the user's manager.
-
MaxLogins
-
Gets or sets the maximum number of simultaneous logins.
-
MaxStorage
-
Gets and set the maximum amount of disk space, in kilobytes, that the user can use.
-
NamePrefix
-
Gets or sets the name prefix, such as Mr., Ms., or Hon., of the user.
-
NameSuffix
-
Gets or sets the name suffix, such as Jr. or III, of the user.
-
OfficeLocations
-
Gets or sets the office location of the user.
-
OtherName
-
Gets or sets the additional name, such as the nickname, or the middle name of the user.
-
PasswordExpirationDate
-
Gets or sets the date and time when the password of the user expires.
-
PasswordLastChanged
-
Gets the date and time of the last password change.
-
PasswordMinimumLength
-
Gets or sets the minimum number of characters allowed in a password.
-
PasswordRequired
-
Gets or sets a value indicating whether a password is required.
-
Picture
-
Gets or sets the picture of the user.
-
PostalAddresses
-
Gets or sets the post office addresses of the user.
-
PostalCodes
-
Gets or sets the postal code of the user.
-
Profile
-
Gets or sets the user's profile path.
-
RequireUniquePassword
-
Gets or sets a value indicating whether a new password must be different from the ones in the password history.
-
SeeAlso
-
Gets or sets the array of ADS paths of other directory objects related to this user.
-
TelephoneHome
-
Gets or sets the home phone number of the user.
-
TelephoneMobile
-
Gets or sets the mobile phone number of the user.
-
TelephoneNumber
-
Gets or sets the work-related phone number of the user.
-
TelephonePager
-
Gets or sets the pager number of the user.
-
Title
-
Gets or sets the user's title within the organization.
Details
ChangePassword()
Changes the user password from the specified old value to a new value.
void ChangePassword(string oldPassword, string newPassword)
Parameters
- oldPassword – the current password.
- newPassword – the new password.
Remarks
To change the password with this method, the caller must have the Change Password permission granted via security roles.
Examples
The following code example changes a user password.
- PowerShell
-
`[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") # Connect to the Adaxes service. $ns = New-Object("Softerra.Adaxes.Adsi.AdmNamespace") $service = $ns.GetServiceDirectly("localhost") # Bind to user. $userDN = "CN=John Smith,CN=Users,DC=domain,DC=com" $user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0) # Change user password. $user.ChangePassword("old password", "new password") - C#
-
using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { // Connect to the Adaxes service. AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to user. const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com"; IADsUser user = (IADsUser)service.OpenObject( userPath, null, null, 0); // Change user password. user.ChangePassword("old password", "new password"); } }
Groups()
Returns a collection of group objects where the user is a member. The method returns an IADsMembers interface which you can use to enumerate all the groups in the collection.
IADsMembers Groups()
Examples
The following code example examines the group membership of a user.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") # Connect to the Adaxes service. $ns = New-Object("Softerra.Adaxes.Adsi.AdmNamespace") $service = $ns.GetServiceDirectly("localhost") # Bind to user. $userDN = "CN=John Smith,CN=Users,DC=domain,DC=com" $user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0) foreach($group in $user.Groups()) { Write-Host $group.Name } - C#
-
using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { // Connect to the Adaxes service. AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to user. const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com"; IADsUser user = (IADsUser)service.OpenObject(userPath, null, null, 0); foreach (IADs group in user.Groups()) { Console.WriteLine(group.Name); } } }
SetPassword()
Sets the user's password to the specified value. The user account must have been created and stored in the directory using IADs::SetInfo before SetPassword is called.
void SetPassword(string newPassword)
Parameters
- newPassword – the new password.
Remarks
To set the password with this method, the caller must have the Reset Password permission granted via security roles.
Examples
The following code example sets a new password for a user.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") # Connect to the Adaxes service. $ns = New-Object("Softerra.Adaxes.Adsi.AdmNamespace") $service = $ns.GetServiceDirectly("localhost") # Bind to user. $userDN = "CN=John Smith,CN=Users,DC=domain,DC=com" $user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0) # Set the user password. $user.SetPassword("secret") - C#
-
using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { // Connect to the Adaxes service. AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to user. const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com"; IADsUser user = (IADsUser)service.OpenObject(userPath, null, null, 0); // Set the user password. user.SetPassword("secret"); } }
AccountDisabled
Gets or sets a value indicating whether the account is disabled.
- Type:
- bool
- Access:
- Read/Write
AccountExpirationDate
Gets or sets the expiration date and time of the user account.
- Type:
- DateTime
- Access:
- Read/Write
BadLoginAddress
Gets the address of the last node considered a possible intruder.
- Type:
- string
- Access:
- Read-only
BadLoginCount
Gets the number of the bad logon attempts since last reset.
- Type:
- int
- Access:
- Read-only
Department
Gets the organizational unit where the user account resides.
- Type:
- string
- Access:
- Read/Write
Description
Gets or sets the description of the user account.
- Type:
- string
- Access:
- Read/Write
Division
Gets or sets the user's division within a company.
- Type:
- string
- Access:
- Read/Write
EmailAddress
Gets or sets the email address of the user.
- Type:
- string
- Access:
- Read/Write
EmployeeID
Gets or sets the employee identification number of the user.
- Type:
- string
- Access:
- Read/Write
Faxnumber
Gets or sets the fax number of the user.
- Type:
- Object
- Access:
- Read/Write
FirstName
Gets or sets the first name of the user.
- Type:
- string
- Access:
- Read/Write
FullName
Gets or sets the full name of the user.
- Type:
- string
- Access:
- Read/Write
GraceLoginsAllowed
Gets or sets the number of times the user can log on after password has expired.
- Type:
- int
- Access:
- Read/Write
GraceLoginsRemaining
Gets or sets the number of grace logins left before locking account.
- Type:
- int
- Access:
- Read/Write
HomeDirectory
Gets or sets the home directory of the user.
- Type:
- string
- Access:
- Read/Write
HomePage
Gets or sets the path to the home page of the user.
- Type:
- string
- Access:
- Read/Write
IsAccountLocked
Gets or sets a value indicating whether the user account is locked out.
- Type:
- bool
- Access:
- Read/Write
Languages
Gets or sets an array of language names for the user.
- Type:
- Object
- Access:
- Read/Write
LastFailedLogin
Gets the date and time of the last failed network login.
- Type:
- DateTime
- Access:
- Read-only
LastLogin
Gets the date and time of the last network login.
- Type:
- DateTime
- Access:
- Read-only
LastLogoff
Gets the date and time of the last network logoff.
- Type:
- DateTime
- Access:
- Read-only
LastName
Gets or sets the last name of the user.
- Type:
- string
- Access:
- Read/Write
LoginHours
Gets or sets the days of the week and time periods when logons are permitted for the user.
- Type:
- Object
- Access:
- Read/Write
LoginScript
Gets or sets the user's login script path.
- Type:
- string
- Access:
- Read/Write
LoginWorkstations
Gets or sets the string addresses or names of workstations from which the user can log on.
- Type:
- Object
- Access:
- Read/Write
Manager
Gets or sets the distinguished name of the user's manager.
- Type:
- string
- Access:
- Read/Write
MaxLogins
Gets or sets the maximum number of simultaneous logins.
- Type:
- int
- Access:
- Read/Write
MaxStorage
Gets and set the maximum amount of disk space, in kilobytes, that the user can use.
- Type:
- int
- Access:
- Read/Write
NamePrefix
Gets or sets the name prefix, such as Mr., Ms., or Hon., of the user.
- Type:
- string
- Access:
- Read/Write
NameSuffix
Gets or sets the name suffix, such as Jr. or III, of the user.
- Type:
- string
- Access:
- Read/Write
OfficeLocations
Gets or sets the office location of the user.
- Type:
- Object
- Access:
- Read/Write
OtherName
Gets or sets the additional name, such as the nickname, or the middle name of the user.
- Type:
- string
- Access:
- Read/Write
PasswordExpirationDate
Gets or sets the date and time when the password of the user expires.
- Type:
- DateTime
- Access:
- Read/Write
PasswordLastChanged
Gets the date and time of the last password change.
- Type:
- DateTime
- Access:
- Read-only
PasswordMinimumLength
Gets or sets the minimum number of characters allowed in a password.
- Type:
- int
- Access:
- Read/Write
PasswordRequired
Gets or sets a value indicating whether a password is required.
- Type:
- bool
- Access:
- Read/Write
Picture
Gets or sets the picture of the user.
- Type:
- Object
- Access:
- Read/Write
PostalAddresses
Gets or sets the post office addresses of the user.
- Type:
- Object
- Access:
- Read/Write
PostalCodes
Gets or sets the postal code of the user.
- Type:
- Object
- Access:
- Read/Write
Profile
Gets or sets the user's profile path.
- Type:
- string
- Access:
- Read/Write
RequireUniquePassword
Gets or sets a value indicating whether a new password must be different from ones in the password history.
- Type:
- bool
- Access:
- Read/Write
SeeAlso
Gets or sets the array of ADS paths of other directory objects related to this user.
- Type:
- Object
- Access:
- Read/Write
TelephoneHome
Gets or sets the home phone number of the user.
- Type:
- Object
- Access:
- Read/Write
TelephoneMobile
Gets or sets the mobile phone number of the user.
- Type:
- Object
- Access:
- Read/Write
TelephoneNumber
Gets or sets the work-related phone number of the user.
- Type:
- Object
- Access:
- Read/Write
TelephonePager
Gets or sets the pager phone number of the user.
- Type:
- Object
- Access:
- Read/Write
Title
Gets or sets the user's title within the organization.
- Type:
- string
- Access:
- Read/Write
Requirements
Minimum required version: 2009.1