Пример #1
0
        public static void UndoImpersonate()
        {
            var stack = ContextItems.Get <List <UserIdName> >("ImpersonationStack", null);

            if (stack != null && stack.Count > 0)
            {
                stack.RemoveAt(stack.Count - 1);
            }
        }
Пример #2
0
        public static void Impersonate(Int64 userId, string username)
        {
            var stack = ContextItems.Get <List <UserIdName> >("ImpersonationStack", null);

            if (stack != null)
            {
                stack.Add(new UserIdName(userId, username));
                return;
            }
            else
            {
                stack = new List <UserIdName>();
                stack.Add(new UserIdName(userId, username));
                ContextItems.Set("ImpersonationStack", stack);
            }
        }