UserPrincipal Class

Encapsulates principals that are user accounts.

Namespace:  System.DirectoryServices.AccountManagement
Assembly:  System.DirectoryServices.AccountManagement (in System.DirectoryServices.AccountManagement.dll)

[DirectoryRdnPrefixAttribute("CN")]
[DirectoryServicesPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = true)]
[DirectoryServicesPermissionAttribute(SecurityAction.InheritanceDemand, Unrestricted = true)]
public class UserPrincipal : AuthenticablePrincipal

The UserPrincipal type exposes the following members.

  NameDescription
Public methodUserPrincipal(PrincipalContext)Initializes a new instance of the UserPrincipal class by using the specified context.
Public methodUserPrincipal(PrincipalContext, String, String, Boolean)Initializes a new instance of the UserPrincipal class by using the specified context, SAM account name, password, and enabled value.
Top

  NameDescription
Public propertyAccountExpirationDateGets or sets a Nullable DateTime that specifies the date and time that the account expires. (Inherited from AuthenticablePrincipal.)
Public propertyAccountLockoutTimeGets the Nullable DateTime that specifies the date and time that the account was locked out. (Inherited from AuthenticablePrincipal.)
Public propertyAdvancedSearchFilterReturns an AdvancedSearchFilter object, for use with Query By Example to set read-only properties before passing the object to the PrincipalSearcher. (Overrides AuthenticablePrincipal.AdvancedSearchFilter.)
Public propertyAllowReversiblePasswordEncryptionGets or sets a Boolean value that specifies whether reversible password encryption is enabled for this account. (Inherited from AuthenticablePrincipal.)
Public propertyBadLogonCountGets the number of logon attempts using incorrect credentials for this account. (Inherited from AuthenticablePrincipal.)
Public propertyCertificatesGets a X509Certificate2Collection that contains the X509 certificates for this account. (Inherited from AuthenticablePrincipal.)
Public propertyContextGets a principal context that is associated with the principal. (Inherited from Principal.)
Protected propertyContextRawGets a principal context that is associated with this principal. (Inherited from Principal.)
Public propertyContextTypeGets the context type enumeraton value that specifies the type of principal context associated with this principal. (Inherited from Principal.)
Public propertyStatic memberCurrentGets a user principal object that represents the current user under which the thread is running.
Public propertyDelegationPermittedGets or sets a Nullable Boolean value that specifies whether the account may be delegated. (Inherited from AuthenticablePrincipal.)
Public propertyDescriptionGets or sets the description of the principal. (Inherited from Principal.)
Public propertyDisplayNameGets or sets the display name for this principal. (Inherited from Principal.)
Public propertyDistinguishedNameGets the distinguished name (DN) for this principal. (Inherited from Principal.)
Public propertyEmailAddressGets or sets the e-mail address for this account.
Public propertyEmployeeIdGets or sets the employee ID for this user principal.
Public propertyEnabledGets or sets a Nullable Boolean value that specifies whether this account is enabled for authentication. (Inherited from AuthenticablePrincipal.)
Public propertyGivenNameGets or sets the given name for the user principal.
Public propertyGuidGets the GUID associated with this principal. (Inherited from Principal.)
Public propertyHomeDirectoryGets or sets the home directory for this account. (Inherited from AuthenticablePrincipal.)
Public propertyHomeDriveGets or sets the home drive for this account. (Inherited from AuthenticablePrincipal.)
Public propertyLastBadPasswordAttemptGets the Nullable DateTime that specifies the date and time of the last incorrect password attempt on this account. (Inherited from AuthenticablePrincipal.)
Public propertyLastLogonGets the Nullable DateTime that specifies the date and time of the last logon for this account. (Inherited from AuthenticablePrincipal.)
Public propertyLastPasswordSetGets the Nullable DateTime that specifies the last date and time that the password was set for this account. (Inherited from AuthenticablePrincipal.)
Public propertyMiddleNameGets or sets the middle name for the user principal.
Public propertyNameGets or sets the name of this principal. (Inherited from Principal.)
Public propertyPasswordNeverExpiresGets or sets a Boolean value that specifies whether the password expires for this account. (Inherited from AuthenticablePrincipal.)
Public propertyPasswordNotRequiredGets or sets a Boolean value that specifies whether a password is required for this account. (Inherited from AuthenticablePrincipal.)
Public propertyPermittedLogonTimesGets or sets the times when the principal can logon. (Inherited from AuthenticablePrincipal.)
Public propertyPermittedWorkstationsGets the list of workstations that this principal is permitted to log into. (Inherited from AuthenticablePrincipal.)
Public propertySamAccountNameGets or sets the SAM account name for this principal. (Inherited from Principal.)
Public propertyScriptPathGets or sets the script path for this account. (Inherited from AuthenticablePrincipal.)
Public propertySidGets the Security ID (SID) of the principal. (Inherited from Principal.)
Public propertySmartcardLogonRequiredGets or sets a Boolean value that specifies whether a smartcard is required to log on to the account. (Inherited from AuthenticablePrincipal.)
Public propertyStructuralObjectClassGets the structural object class directory attribute. (Inherited from Principal.)
Public propertySurnameGets or sets the surname for the user principal.
Public propertyUserCannotChangePasswordGets or sets a Boolean value that specifies whether the user can change the password for this account. Do not use this with a ComputerPrincipal. (Inherited from AuthenticablePrincipal.)
Public propertyUserPrincipalNameGets or sets the user principal name (UPN) associated with this principal. (Inherited from Principal.)
Public propertyVoiceTelephoneNumberGets or sets the voice telephone number for the user principal.
Top

  NameDescription
Public methodChangePasswordChanges the account password from the old password to the new password. Do not use this with a ComputerPrincipal. (Inherited from AuthenticablePrincipal.)
Protected methodCheckDisposedOrDeletedDetermines whether the Dispose or Delete methods have been called on this class. This method is called by classes that derive from this principal class. (Inherited from Principal.)
Public methodDeleteDeletes the principal object from the store. (Inherited from Principal.)
Public methodDisposeDisposes the current instance of the Principal object. (Inherited from Principal.)
Public methodEqualsReturns a Boolean value that specifies whether the supplied object is equal to the current object. (Inherited from Principal.)
Public methodExpirePasswordNowExpires the password for this account. This will force the user to change his/her password at the next logon. (Inherited from AuthenticablePrincipal.)
Protected methodExtensionGetRetrieves an attribute of an extended class object. (Inherited from Principal.)
Protected methodExtensionSetSets the value of an attribute in an extended class. (Inherited from Principal.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodStatic memberFindByBadPasswordAttemptReturns a collection of [T:System.DirectoryServices.AccountManagement.PrincipleSearchResult'1] objects for users that have an incorrect password attempt recorded in the specified date and time range.
Public methodStatic memberFindByExpirationTimeReturns a collection of [T:System.DirectoryServices.AccountManagement.PrincipleSearchResult'1] objects for users that have an account expiration time in the specified date and time range.
Public methodStatic memberFindByIdentity(PrincipalContext, String)Returns a user principal object that matches the specified identity value.
Public methodStatic memberFindByIdentity(PrincipalContext, IdentityType, String)Returns a user principal object that matches the specified identity type, and value. This version of the FindByIdentity method determines the format of the identity value.
Public methodStatic memberFindByLockoutTimeReturns a collection of [T:System.DirectoryServices.AccountManagement.PrincipleSearchResult'1] objects for users that have an account lockout time in the specified date and time range.
Public methodStatic memberFindByLogonTimeReturns a collection of [T:System.DirectoryServices.AccountManagement.PrincipleSearchResult'1] objects for users that have account logon recorded in the specified date and time range.
Public methodStatic memberFindByPasswordSetTimeReturns a collection of [T:System.DirectoryServices.AccountManagement.PrincipleSearchResult'1] objects for users that have set their password within the specified date and time range.
Public methodGetAuthorizationGroupsReturns a collection of principal objects that contains all the authorization groups of which this user is a member. This function only returns groups that are security groups; distribution groups are not returned.
Public methodGetGroups()Returns a collection of group objects that specify the groups of which the current principal is a member. (Inherited from Principal.)
Public methodGetGroups(PrincipalContext)Returns a collection of group objects that the principal is a member of and that exist in the store provided by the specified context parameter. (Inherited from Principal.)
Public methodGetHashCodeRetrieves the hash created from the contents of the principal object, suited for use in hashing algorithms and data structures like a hash table. (Inherited from Principal.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetUnderlyingObjectReturns the underlying DirectoryEntry object that provides the contact data for the principal object. (Inherited from Principal.)
Public methodGetUnderlyingObjectTypeReturns the underlying object type. (Inherited from Principal.)
Public methodIsAccountLockedOutReturns a Boolean value that specifies whether the account is currently locked out. (Inherited from AuthenticablePrincipal.)
Public methodIsMemberOf(GroupPrincipal)Returns a Boolean value that specifies whether the principal is a member of the specified group. (Inherited from Principal.)
Public methodIsMemberOf(PrincipalContext, IdentityType, String)Returns a Boolean value that specifies whether the principal is a member of the group specified by identity type and value. (Inherited from Principal.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodRefreshExpiredPasswordRefreshes an expired password. (Inherited from AuthenticablePrincipal.)
Public methodSave()Saves the changes that were made on the principal object to the store. If this is a new principal object, this method inserts it into the store. (Inherited from Principal.)
Public methodSave(PrincipalContext)Saves the changes that were made on the principal object to the store. If this is a new principal object, this method inserts it into the specified context. If the principal has already been persisted, it is moved from the original context to the specified context. (Inherited from Principal.)
Public methodSetPasswordSets the account password to the specified value. (Inherited from AuthenticablePrincipal.)
Public methodToStringReturns a user friendly string representation of the current principal object. (Inherited from Principal.)
Public methodUnlockAccountUnlocks the account if it is currently locked out. (Inherited from AuthenticablePrincipal.)
Top

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft