Click or drag to resize

UserInfo Class

Represents information about a local user or a domain user (e.g., from Active Directory).
Inheritance Hierarchy
SystemObject
  GSF.IdentityUserInfo

Namespace: GSF.Identity
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.181-beta
Syntax
public sealed class UserInfo : ISupportLifecycle, 
	IDisposable, IPersistSettings
View Source

The UserInfo type exposes the following members.

Constructors
 NameDescription
Public methodUserInfo(String) Initializes a new instance of the UserInfo class.
Public methodUserInfo(String, String) Initializes a new instance of the UserInfo class.
Top
Properties
 NameDescription
Public propertyAccountCreationDate Gets the DateTime when the account was created.
Public propertyAccountIsDisabled Gets flag that determines if account is disabled for this user.
Public propertyAccountIsLockedOut Gets flag that determines if account is locked-out for this user.
Public propertyCity Gets the City where the user works.
Public propertyCompany Gets the Company of the user.
Public propertyStatic memberCurrentUserID Gets the ID name of the current user.
Public propertyStatic memberCurrentUserInfo Gets the UserInfo object for the CurrentUserID.
Public propertyDepartment Gets the Department where the user works.
Public propertyDescription Gets the description specified for the user.
Public propertyDisplayName Gets the Display Name the user.
Public propertyDomain Gets the domain for the user.
Public propertyDomainRespondsForUser Gets flag that determines if domain is responding to user existence.
Public propertyEmail Gets the E-Mail address of the user.
Public propertyExists Gets flag that determines if user exists.
Public propertyFirstName Gets the First Name of the user.
Public propertyFullName Gets the Full Name of the user.
Public propertyGroups Gets all the groups associated with the user - this includes local groups and Active Directory groups if applicable.
Public propertyIsLocalAccount Gets flag that determines if this UserInfo instance is based on a local account instead of found through LDAP.
Public propertyLastLogon Gets the last login time of the user.
Public propertyLastName Gets the Last Name of the user.
Public propertyLdapID Gets the ID of the user in LDAP format.
Public propertyLdapPath Gets LDAP path defined for this user, if any.
Public propertyLocalGroups Gets the local groups the user is a member of.
Public propertyLoginID Gets the Login ID of the user.
Public propertyStatic memberMachineIsJoinedToDomain Gets a boolean value that indicates whether the current machine is joined to a domain (non-local such as AD or LDAP).
Public propertyMailbox Gets the Mailbox address of where the user works.
Public propertyMaximumPasswordAge Gets this maximum password age for the user.
Public propertyMiddleInitial Gets the Middle Initial of the user.
Public propertyNextPasswordChangeDate Gets the DateTime, in UTC, of next password change for the user.
Public propertyOffice Gets the Office location of the user.
Public propertyPassthroughPrincipal Gets or sets the principal used for passthrough authentication.
Public propertyPasswordCannotChange Gets flag that determines if account password cannot change for this user.
Public propertyPasswordDoesNotExpire Gets flag that determines if account password does not expire for this user.
Public propertyPersistSettings Gets or sets a boolean value that indicates whether the settings of UserInfo object are to be saved to the config file.
Public propertyStatic memberRemoteUserID Gets the LoginID of the remote web user.
Public propertyStatic memberRemoteUserInfo Gets the UserInfo object for the RemoteUserID.
Public propertySettingsCategory Gets or sets the category under which the settings of UserInfo object are to be saved to the config file if the PersistSettings property is set to true.
Public propertyTelephone Gets the Telephone Number of the user.
Public propertyTitle Gets the Title of the user.
Public propertyUserAccountControl Gets the account control information of the user.
Public propertyUserName Gets the user name of the user.
Public propertyWebpage Gets the web page address of the user.
Top
Methods
 NameDescription
Public methodStatic memberAddUserToLocalGroup Adds an existing user to the specified local groupName.
Public methodStatic memberCode exampleAuthenticateUser(String, String, String) Authenticates the specified user credentials.
Public methodStatic memberCode exampleAuthenticateUser(String, String, String, String) Authenticates the specified user credentials.
Public methodChangePassword Attempts to change the user's password.
Public methodStatic memberCreateLocalGroup Creates a new local group if it does not exist already.
Public methodStatic memberCreateLocalUser Creates a new local user if it does not exist already.
Public methodCode exampleDefinePrivilegedAccount Defines the credentials of a privileged domain account that can be used for impersonation prior to the retrieval of user information from the Active Directory.
Public methodDispose Releases all the resources used by the UserInfo object.
Public methodStatic memberCode exampleEndImpersonation Ends the impersonation of the specified user.
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Protected methodFinalize Releases the unmanaged resources before the UserInfo object is reclaimed by GC.
(Overrides ObjectFinalize)
Public methodStatic memberGetBuiltInLocalGroups Returns a sorted list of the common built-in local groups. On Windows these groups have a domain name of BUILTIN.
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodStatic memberGetLocalGroupUserList Gets a list of users that exist in the specified local groupName.
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodGetUserPropertyValue Returns the value for specified active directory property.
Public methodStatic memberGroupNameToSID Converts the given group name to the SID corresponding to that name.
Public methodImpersonatePrivilegedAccount Impersonates the defined privileged domain account.
Public methodStatic memberCode exampleImpersonateUser Impersonates the specified user.
Public methodInitialize Initializes the UserInfo object.
Public methodStatic memberIsGroupSID Determines whether the given security identifier identifies a group.
Public methodStatic memberIsLocalDomain Determines if specified domain is the local domain (i.e., local machine).
Public methodStatic memberIsUserSID Determines whether the given security identifier identifies a user account.
Public methodLoadSettings Loads saved settings for the UserInfo object from the config file if the PersistSettings property is set to true.
Public methodStatic memberLocalGroupExists Determines if local group exists.
Public methodStatic memberLocalUserExists Determines if local user exists.
Public methodStatic memberRemoveLocalGroup Removes local group if it exists.
Public methodStatic memberRemoveLocalUser Removes local user if it exists.
Public methodStatic memberRemoveUserFromLocalGroup Removes an existing user from the specified local groupName.
Public methodSaveSettings Saves settings for the UserInfo object to the config file if the PersistSettings property is set to true.
Public methodStatic memberSetLocalUserPassword Sets local user's password.
Public methodStatic memberSIDToAccountName Converts the given SID to the corresponding account name.
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Public methodStatic memberUserIsInLocalGroup Determines if user is in the specified local groupName.
Public methodStatic memberUserNameToSID Converts the given user name to the SID corresponding to that name.
Top
Events
 NameDescription
Public eventDisposed Occurs when the class has been disposed.
Top
Fields
 NameDescription
Public fieldStatic memberBuiltInGroupName Localized version of Windows "BUILTIN" local permissions group name.
Public fieldStatic memberDefaultPersistSettings Specifies the default value for the PersistSettings property.
Public fieldStatic memberDefaultSettingsCategory Specifies the default value for the SettingsCategory property.
Public fieldStatic memberNTAuthorityGroupName Localized version of Windows "NT AUTHORITY" local permissions group name.
Public fieldStatic memberNTServiceGroupName Localized version of Windows "NT SERVICE" local Windows services group name.
Top
Extension Methods
 NameDescription
Public Extension MethodGetEnumValueOrDefault Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Public Extension MethodGetEnumValueOrDefaultT Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Top
Remarks
See http://msdn.microsoft.com/en-us/library/ms677980.aspx for more information on active directory properties.
Example
This example shows how to retrieve user information from Active Directory:
C#
using System;
using GSF.Identity;

class Program
{
    static void Main(string[] args)
    {
        // Retrieve and display user information from Active Directory.
        using (UserInfo user = new UserInfo("XYZCorp\\johndoe"))
        {
            Console.WriteLine(string.Format("First Name: {0}", user.FirstName));
            Console.WriteLine(string.Format("Last Name: {0}", user.LastName));
            Console.WriteLine(string.Format("Middle Initial: {0}", user.MiddleInitial));
            Console.WriteLine(string.Format("Email Address: {0}", user.Email));
            Console.WriteLine(string.Format("Telephone Number: {0}", user.Telephone));
        }

        Console.ReadLine();
    }
}
This example shows the config file section that can be used to specify the domain account to be used for Active Directory queries:
C#
<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="categorizedSettings" type="GSF.Configuration.CategorizedSettingsSection, GSF.Core" />
  </configSections>
  <categorizedSettings>
    <activeDirectory>
      <add name="PrivilegedDomain" value="" description="Domain of privileged domain user account."
        encrypted="false" />
      <add name="PrivilegedUserName" value="" description="Username of privileged domain user account."
        encrypted="false" />
      <add name="PrivilegedPassword" value="" description="Password of privileged domain user account."
        encrypted="true" />
    </activeDirectory>
  </categorizedSettings>
</configuration>
See Also