Exemplo n.º 1
0
        public IDisposable Impersonate()
        {
            if (!this.isImpersonated)
            {
                return(null);
            }
            HostedInnerImpersonationContext context = null;

            lock (this.tokenHandle)
            {
                context = HostedInnerImpersonationContext.UnsafeCreate(this.tokenHandle.DangerousGetHandle());
                GC.KeepAlive(this.tokenHandle);
            }
            return(context);
        }
Exemplo n.º 2
0
        public IDisposable Impersonate()
        {
            if (!isImpersonated)
            {
                return(null);
            }

            Fx.Assert(tokenHandle != null, "The token handle was incorrectly released earlier.");
            HostedInnerImpersonationContext context = null;

            lock (tokenHandle)
            {
                context = HostedInnerImpersonationContext.UnsafeCreate(tokenHandle.DangerousGetHandle());
                GC.KeepAlive(tokenHandle);
            }
            return(context);
        }