Esempio n. 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);
            }
        }
Esempio n. 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);
            }
        }