C# Класс LazyCopy.Utilities.Impersonator

Contains helper methods for user impersonation.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
DuplicateProcessHandle ( Process process ) : IntPtr

Duplicates handle for the process given.

Описание методов

Impersonate() публичный статический Метод

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.
Результат System.Security.Principal.WindowsImpersonationContext

Impersonate() публичный статический Метод

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.
Результат System.Security.Principal.WindowsImpersonationContext