C# Class LazyCopy.Utilities.Impersonator

Contains helper methods for user impersonation.
Afficher le fichier Open project: aleksk/LazyCopy Class Usage Examples

Méthodes publiques

Méthode Description
Impersonate ( string domainUser ) : System.Security.Principal.WindowsImpersonationContext

Impersonates the specified user within the Explorer process context.
Explorer process is vital for the system and should always be there, if the user is logged in.

Impersonate ( string domainUser, Predicate processFilter ) : System.Security.Principal.WindowsImpersonationContext

Impersonates the specified user.

This method looks for the existing domainUser process running in the system, obtains and duplicates its token, and uses it to impersonate the caller. So it won't work, if the user is logged out or has no processes running.

Private Methods

Méthode Description
DuplicateProcessHandle ( Process process ) : IntPtr

Duplicates handle for the process given.

Method Details

Impersonate() public static méthode

Impersonates the specified user within the Explorer process context.
Explorer process is vital for the system and should always be there, if the user is logged in.
is or empty. is not in the DOMAIN\username format. /// No processes are running for the . /// -or- /// Process handle cannot be duplicated. ///
public static Impersonate ( string domainUser ) : System.Security.Principal.WindowsImpersonationContext
domainUser string The domain user.
Résultat System.Security.Principal.WindowsImpersonationContext

Impersonate() public static méthode

Impersonates the specified user.
This method looks for the existing domainUser process running in the system, obtains and duplicates its token, and uses it to impersonate the caller. So it won't work, if the user is logged out or has no processes running.
is or empty. is not in the DOMAIN\username format. /// No processes are running for the . /// -or- /// Process handle cannot be duplicated. ///
public static Impersonate ( string domainUser, Predicate processFilter ) : System.Security.Principal.WindowsImpersonationContext
domainUser string The domain user.
processFilter Predicate Predicate to find the process suitable for impersonation. If it's , the first 's process will be used.
Résultat System.Security.Principal.WindowsImpersonationContext