本文整理匯總了C#中System.Security.Principal.WindowsImpersonationContext.Undo方法的典型用法代碼示例。如果您正苦於以下問題:C# WindowsImpersonationContext.Undo方法的具體用法?C# WindowsImpersonationContext.Undo怎麽用?C# WindowsImpersonationContext.Undo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Security.Principal.WindowsImpersonationContext
的用法示例。
在下文中一共展示了WindowsImpersonationContext.Undo方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: RevertToImpersonatedUser
public static void RevertToImpersonatedUser(WindowsImpersonationContext _serviceAccountContext)
{
if (_serviceAccountContext != null)
{
_serviceAccountContext.Undo();
}
}
示例2: EndImpersonation
/// <summary>
/// Ends the impersonation of the specified user.
/// </summary>
/// <param name="impersonatedUser"><see cref="WindowsImpersonationContext"/> of the impersonated user.</param>
/// <example>
/// This example shows how to terminate an active user impersonation:
/// <code>
/// using System;
/// using System.IO;
/// using System.Security.Principal;
/// using PCS.Identity;
///
/// class Program
/// {
/// static void Main(string[] args)
/// {
/// // Impersonate user.
/// WindowsImpersonationContext context = UserInfo.ImpersonateUser("XYZCorp", "johndoe", "password");
/// // Perform operation requiring elevated previleges.
/// Console.WriteLine(File.ReadAllText(@"\\server\share\file.xml"));
/// // End the impersonation.
/// UserInfo.EndImpersonation(context);
///
/// Console.ReadLine();
/// }
/// }
/// </code>
/// </example>
public static void EndImpersonation(WindowsImpersonationContext impersonatedUser)
{
if (impersonatedUser != null)
{
impersonatedUser.Undo();
impersonatedUser.Dispose();
}
impersonatedUser = null;
}
示例3: deshacerImpersonation
public static void deshacerImpersonation(WindowsImpersonationContext impersonationContext)
{
impersonationContext.Undo();
}
示例4: StopImpersonateUser
/// <summary>
/// Stops impersonating authorized user.
/// </summary>
/// <param name="user"></param>
public static void StopImpersonateUser(WindowsImpersonationContext user)
{
user.Undo();
}
示例5: ReImpersonate
internal static void ReImpersonate(WindowsImpersonationContext impersonation){
impersonation.Undo();
}
示例6: Log_off
static public void Log_off(WindowsImpersonationContext wic)
{
wic.Undo();
}
示例7: RevertImpersonation
/// <summary>
/// Releases an impersonation context and releases associated resources
/// </summary>
/// <param name="context">WindowsImpersonation context created with ImpersonateUser</param>
public static void RevertImpersonation(WindowsImpersonationContext context)
{
context.Undo();
context.Dispose();
}