상속: IDisposable
예제 #1
0
        public static bool RunAs(string userName, string domain, string password, Action action)
        {
            var result = false;

            using (var impersonator = new Impersonator())
            {
                if (impersonator.Impersonate(userName, domain, password))
                {
                    action();
                    result = true;
                }
            }

            return(result);
        }
예제 #2
0
        public static bool RunAs(string userName, string domain, string password, Action action)
        {
            var result = false;
            using(var impersonator = new Impersonator())
            {
                if(impersonator.Impersonate(userName, domain, password))
                {
                    action();
                    result = true;
                }
            }

            return result;
        }