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 association of the user, and for setting or changing the password.

Inheritance: IADs

Methods

  • Method

  • Description

  • ChangePassword()

  • Changes the user password from the specified old value to a new value.

  • Groups()

  • Returns a collection of the ADSI group objects to which this user belongs.

  • SetPassword()

  • Sets the user password to a 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 an 'Intruder'.

  • BadLoginCount

  • Gets the number of the bad logon attempts since last reset.

  • Department

  • Gets the organizational unit (OU), to which the user belongs.

  • Description

  • Gets or sets the description of the user account.

  • Division

  • Gets or sets the division within a company (organization).

  • EmailAddress

  • Gets or sets the email address of the user.

  • EmployeeID

  • Gets or sets employee identification number of the user.

  • Faxnumber

  • Gets or sets the fax phone 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 string elements, where each element represents a language name 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 time periods during each day of week during which logons are permitted for the user.

  • LoginScript

  • Gets or sets the user's login script path.

  • LoginWorkstations

  • Gets or sets addresses or names of workstations, of the string data type, from which the user can log on.

  • Manager

  • Gets or sets the distinguished name (DN) of the manager of the user.

  • 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 ones in the password history list.

  • 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 phone 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 - A string that contains the current password.
  • newPassword - A string that contains the new password.

Remarks

In Adaxes, the caller must have the Change Password right granted via security roles to change the password with this method.

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
{
    private 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 the ADSI group objects to which this user belongs. The method returns an IADsMembers interface through which you can 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;

internal class Program
{
    private 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 password to a 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

The newPassword parameter is a string that contains the new password.

Remarks

In Adaxes, the caller must have the Reset Password right granted via security roles to set the password with this method.

Examples

The following code example sets the user password, if you have the permission to do so.

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;

internal class Program
{
    private 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 an '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 (OU), to which the user belongs.

  • 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 division within a company (organization).

  • Type:
  • string
  • Access:
  • Read/Write

EmailAddress

Gets or sets the email address of the user.

  • Type:
  • string
  • Access:
  • Read/Write

EmployeeID

Gets or sets employee identification number of the user.

  • Type:
  • string
  • Access:
  • Read/Write

Faxnumber

Gets or sets the fax phone 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 string elements, where each element represents a language name 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 time periods during each day of week during which 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 addresses or names of workstations, of the string data type, from which the user can log on.

  • Type:
  • Object
  • Access:
  • Read/Write

Manager

Gets or sets the distinguished name (DN) of the manager of the user.

  • 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 list.

  • 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

See also