C# 클래스 GSF.Identity.UserInfo

Represents information about a local user or a domain user (e.g., from Active Directory).
See http://msdn.microsoft.com/en-us/library/ms677980.aspx for more information on active directory properties.
상속: ISupportLifecycle, IPersistSettings
파일 보기 프로젝트 열기: GridProtectionAlliance/gsf 1 사용 예제들

Private Properties

프로퍼티 타입 설명
Dispose void
GetNameElements string[]
ValidateGroupName string

공개 메소드들

메소드 설명
AddUserToLocalGroup ( string groupName, string userName ) : bool

Adds an existing user to the specified local groupName.

This function will handle Windows service virtual accounts by specifying the complete virtual account name, such as @"NT SERVICE\MyService", as the userName. This function can also add Active Directory user accounts and groups to the local group the when the userName is prefixed with a domain name and a backslash "\".

AuthenticateUser ( string domain, string userName, string password ) : IPrincipal

Authenticates the specified user credentials.

This method always returns null under Mono deployments.

AuthenticateUser ( string domain, string userName, string password, string &errorMessage ) : IPrincipal

Authenticates the specified user credentials.

This method always returns null under Mono deployments.

ChangePassword ( string oldPassword, string newPassword ) : void

Attempts to change the user's password.

CreateLocalGroup ( string groupName, string groupDescription = null ) : bool

Creates a new local group if it does not exist already.

CreateLocalUser ( string userName, string password, string userDescription = null ) : bool

Creates a new local user if it does not exist already.

DefinePrivilegedAccount ( string domain, string username, string password ) : void

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.

Dispose ( ) : void

Releases all the resources used by the UserInfo object.

EndImpersonation ( System.Security.Principal.WindowsImpersonationContext impersonatedUser ) : void

Ends the impersonation of the specified user.

GetBuiltInLocalGroups ( ) : string[]

Returns a sorted list of the common built-in local groups. On Windows these groups have a domain name of BUILTIN.

Names in this list will not have a "BUILTIN\" prefix.

GetLocalGroupUserList ( string groupName ) : string[]

Gets a list of users that exist in the specified local groupName.

GetUserPropertyValue ( string propertyName ) : string

Returns the value for specified active directory property.

GroupNameToSID ( string groupName ) : string

Converts the given group name to the SID corresponding to that name.

If the groupName cannot be converted to a SID, groupName will be the return value.

ImpersonatePrivilegedAccount ( ) : System.Security.Principal.WindowsImpersonationContext

Impersonates the defined privileged domain account.

This method always returns null under Mono deployments.

ImpersonateUser ( string domain, string userName, string password ) : System.Security.Principal.WindowsImpersonationContext

Impersonates the specified user.

After impersonating a user the code executes under the impersonated user's identity.

This method always returns null under Mono deployments.

Initialize ( ) : void

Initializes the UserInfo object.

IsGroupSID ( string sid ) : bool

Determines whether the given security identifier identifies a group.

IsLocalDomain ( string domain ) : bool

Determines if specified domain is the local domain (i.e., local machine).

IsUserSID ( string sid ) : bool

Determines whether the given security identifier identifies a user account.

LoadSettings ( ) : void

Loads saved settings for the UserInfo object from the config file if the PersistSettings property is set to true.

LocalGroupExists ( string groupName ) : bool

Determines if local group exists.

LocalUserExists ( string userName ) : bool

Determines if local user exists.

RemoveLocalGroup ( string groupName ) : bool

Removes local group if it exists.

RemoveLocalUser ( string userName ) : bool

Removes local user if it exists.

RemoveUserFromLocalGroup ( string groupName, string userName ) : bool

Removes an existing user from the specified local groupName.

This function will handle Windows service virtual accounts by specifying the complete virtual account name, such as @"NT SERVICE\MyService", as the userName. This function can also remove Active Directory user accounts and groups from the local group the when the userName is prefixed with a domain name and a backslash "\".

SIDToAccountName ( string sid ) : string

Converts the given SID to the corresponding account name.

If the sid cannot be converted to an account name, sid will be the return value.

SaveSettings ( ) : void

Saves settings for the UserInfo object to the config file if the PersistSettings property is set to true.

SetLocalUserPassword ( string userName, string password ) : void

Sets local user's password.

UserInfo ( string loginID ) : System

Initializes a new instance of the UserInfo class.

UserInfo ( string loginID, string ldapPath ) : System

Initializes a new instance of the UserInfo class.

UserIsInLocalGroup ( string groupName, string userName ) : bool

Determines if user is in the specified local groupName.

This function will handle Windows service virtual accounts by specifying the complete virtual account name, such as @"NT SERVICE\MyService", as the userName. This function can also detect Active Directory user accounts and groups that may exist in the local group when the userName is prefixed with a domain name and a backslash "\".

UserNameToSID ( string userName ) : string

Converts the given user name to the SID corresponding to that name.

If the userName cannot be converted to a SID, userName will be the return value.

비공개 메소드들

메소드 설명
Dispose ( bool disposing ) : void

Releases the unmanaged resources used by the UserInfo object and optionally releases the managed resources.

GetNameElements ( string displayName ) : string[]
ValidateGroupName ( string groupName ) : string

메소드 상세

AddUserToLocalGroup() 공개 정적인 메소드

Adds an existing user to the specified local groupName.
This function will handle Windows service virtual accounts by specifying the complete virtual account name, such as @"NT SERVICE\MyService", as the userName. This function can also add Active Directory user accounts and groups to the local group the when the userName is prefixed with a domain name and a backslash "\".
or was null. No or was specified. Could not add user to local group.
public static AddUserToLocalGroup ( string groupName, string userName ) : bool
groupName string Group name to add local user to.
userName string Existing local user name.
리턴 bool

AuthenticateUser() 공개 정적인 메소드

Authenticates the specified user credentials.
This method always returns null under Mono deployments.
public static AuthenticateUser ( string domain, string userName, string password ) : IPrincipal
domain string Domain of user to authenticate.
userName string Username of user to authenticate.
password string Password of user to authenticate.
리턴 IPrincipal

AuthenticateUser() 공개 정적인 메소드

Authenticates the specified user credentials.
This method always returns null under Mono deployments.
public static AuthenticateUser ( string domain, string userName, string password, string &errorMessage ) : IPrincipal
domain string Domain of user to authenticate.
userName string Username of user to authenticate.
password string Password of user to authenticate.
errorMessage string Error message returned, if authentication fails.
리턴 IPrincipal

ChangePassword() 공개 메소드

Attempts to change the user's password.
public ChangePassword ( string oldPassword, string newPassword ) : void
oldPassword string Old password.
newPassword string New password.
리턴 void

CreateLocalGroup() 공개 정적인 메소드

Creates a new local group if it does not exist already.
was null. No was specified. Could not create local group.
public static CreateLocalGroup ( string groupName, string groupDescription = null ) : bool
groupName string Group name to create if it doesn't exist.
groupDescription string Optional group description.
리턴 bool

CreateLocalUser() 공개 정적인 메소드

Creates a new local user if it does not exist already.
or was null. No was specified. Could not create local user.
public static CreateLocalUser ( string userName, string password, string userDescription = null ) : bool
userName string User name to create if it doesn't exist.
password string Password to user for new user.
userDescription string Optional user description.
리턴 bool

DefinePrivilegedAccount() 공개 메소드

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 DefinePrivilegedAccount ( string domain, string username, string password ) : void
domain string Domain of privileged domain user account.
username string Username of privileged domain user account.
password string Password of privileged domain user account.
리턴 void

Dispose() 공개 메소드

Releases all the resources used by the UserInfo object.
public Dispose ( ) : void
리턴 void

EndImpersonation() 공개 정적인 메소드

Ends the impersonation of the specified user.
public static EndImpersonation ( System.Security.Principal.WindowsImpersonationContext impersonatedUser ) : void
impersonatedUser System.Security.Principal.WindowsImpersonationContext of the impersonated user.
리턴 void

GetBuiltInLocalGroups() 공개 정적인 메소드

Returns a sorted list of the common built-in local groups. On Windows these groups have a domain name of BUILTIN.
Names in this list will not have a "BUILTIN\" prefix.
public static GetBuiltInLocalGroups ( ) : string[]
리턴 string[]

GetLocalGroupUserList() 공개 정적인 메소드

Gets a list of users that exist in the specified local groupName.
was null. No was specified. Could not get members for local group.
public static GetLocalGroupUserList ( string groupName ) : string[]
groupName string Group name to remove local user from.
리턴 string[]

GetUserPropertyValue() 공개 메소드

Returns the value for specified active directory property.
public GetUserPropertyValue ( string propertyName ) : string
propertyName string Name of the active directory property whose value is to be retrieved.
리턴 string

GroupNameToSID() 공개 정적인 메소드

Converts the given group name to the SID corresponding to that name.
If the groupName cannot be converted to a SID, groupName will be the return value.
public static GroupNameToSID ( string groupName ) : string
groupName string The group name for which to look up the SID.
리턴 string

ImpersonatePrivilegedAccount() 공개 메소드

Impersonates the defined privileged domain account.
This method always returns null under Mono deployments.
public ImpersonatePrivilegedAccount ( ) : System.Security.Principal.WindowsImpersonationContext
리턴 System.Security.Principal.WindowsImpersonationContext

ImpersonateUser() 공개 정적인 메소드

Impersonates the specified user.

After impersonating a user the code executes under the impersonated user's identity.

This method always returns null under Mono deployments.

public static ImpersonateUser ( string domain, string userName, string password ) : System.Security.Principal.WindowsImpersonationContext
domain string Domain of user to impersonate.
userName string Username of user to impersonate.
password string Password of user to impersonate.
리턴 System.Security.Principal.WindowsImpersonationContext

Initialize() 공개 메소드

Initializes the UserInfo object.
Failed to initialize directory entry for .
public Initialize ( ) : void
리턴 void

IsGroupSID() 공개 정적인 메소드

Determines whether the given security identifier identifies a group.
public static IsGroupSID ( string sid ) : bool
sid string The security identifier.
리턴 bool

IsLocalDomain() 공개 정적인 메소드

Determines if specified domain is the local domain (i.e., local machine).
public static IsLocalDomain ( string domain ) : bool
domain string Domain name to check.
리턴 bool

IsUserSID() 공개 정적인 메소드

Determines whether the given security identifier identifies a user account.
public static IsUserSID ( string sid ) : bool
sid string The security identifier.
리턴 bool

LoadSettings() 공개 메소드

Loads saved settings for the UserInfo object from the config file if the PersistSettings property is set to true.
has a value of null or empty string.
public LoadSettings ( ) : void
리턴 void

LocalGroupExists() 공개 정적인 메소드

Determines if local group exists.
was null. No was specified.
public static LocalGroupExists ( string groupName ) : bool
groupName string Group name to test for existence.
리턴 bool

LocalUserExists() 공개 정적인 메소드

Determines if local user exists.
was null. No was specified.
public static LocalUserExists ( string userName ) : bool
userName string User name to test for existence.
리턴 bool

RemoveLocalGroup() 공개 정적인 메소드

Removes local group if it exists.
was null. No was specified. Could not remove local group.
public static RemoveLocalGroup ( string groupName ) : bool
groupName string Group name to remove if it exists.
리턴 bool

RemoveLocalUser() 공개 정적인 메소드

Removes local user if it exists.
was null. No was specified. Could not remove local user.
public static RemoveLocalUser ( string userName ) : bool
userName string User name to remove if it exists.
리턴 bool

RemoveUserFromLocalGroup() 공개 정적인 메소드

Removes an existing user from the specified local groupName.
This function will handle Windows service virtual accounts by specifying the complete virtual account name, such as @"NT SERVICE\MyService", as the userName. This function can also remove Active Directory user accounts and groups from the local group the when the userName is prefixed with a domain name and a backslash "\".
or was null. No or was specified. Could not remove user from local group.
public static RemoveUserFromLocalGroup ( string groupName, string userName ) : bool
groupName string Group name to remove local user from.
userName string Existing local user name.
리턴 bool

SIDToAccountName() 공개 정적인 메소드

Converts the given SID to the corresponding account name.
If the sid cannot be converted to an account name, sid will be the return value.
public static SIDToAccountName ( string sid ) : string
sid string The SID for which to look up the account name.
리턴 string

SaveSettings() 공개 메소드

Saves settings for the UserInfo object to the config file if the PersistSettings property is set to true.
has a value of null or empty string.
public SaveSettings ( ) : void
리턴 void

SetLocalUserPassword() 공개 정적인 메소드

Sets local user's password.
or was null. No was specified or user does not exist. Could not set password for local user.
public static SetLocalUserPassword ( string userName, string password ) : void
userName string User name to change password for.
password string New password fro user.
리턴 void

UserInfo() 공개 메소드

Initializes a new instance of the UserInfo class.
is a null or empty string.
public UserInfo ( string loginID ) : System
loginID string /// Login ID in 'domain\username' format of the user's account whose information is to be retrieved. Login ID /// can also be specified in 'username' format without the domain name, in which case the domain name will be /// approximated based on the privileged user domain if specified, default logon domain of the host machine /// if available, or the domain of the identity that owns the host process. ///
리턴 System

UserInfo() 공개 메소드

Initializes a new instance of the UserInfo class.
is a null or empty string.
public UserInfo ( string loginID, string ldapPath ) : System
loginID string /// Login ID in 'domain\username' format of the user's account whose information is to be retrieved. Login ID /// can also be specified in 'username' format without the domain name, in which case the domain name will be /// approximated based on the privileged user domain if specified, default logon domain of the host machine /// if available, or the domain of the identity that owns the host process. ///
ldapPath string /// String in 'LDAP://' format that specifies the Active Directory node where search for the user starts. ///
리턴 System

UserIsInLocalGroup() 공개 정적인 메소드

Determines if user is in the specified local groupName.
This function will handle Windows service virtual accounts by specifying the complete virtual account name, such as @"NT SERVICE\MyService", as the userName. This function can also detect Active Directory user accounts and groups that may exist in the local group when the userName is prefixed with a domain name and a backslash "\".
or was null. No or was specified. Could not determine if user was in local group.
public static UserIsInLocalGroup ( string groupName, string userName ) : bool
groupName string Group name to test.
userName string User name to test.
리턴 bool

UserNameToSID() 공개 정적인 메소드

Converts the given user name to the SID corresponding to that name.
If the userName cannot be converted to a SID, userName will be the return value.
public static UserNameToSID ( string userName ) : string
userName string The user name for which to look up the SID.
리턴 string