public ImpersonationContext(string targetUsername)
        {
            if (targetUsername == null)
                throw new ArgumentNullException("targetUsername");

            TargetUsername = targetUsername;
            current = this;
        }
示例#2
0
        public ImpersonationContext(string targetUsername)
        {
            if (targetUsername == null)
            {
                throw new ArgumentNullException("targetUsername");
            }

            TargetUsername = targetUsername;
            current        = this;
        }
        public object BeforeSendRequest(ref Message request, IClientChannel channel)
        {
            ImpersonationContext impersonationContext = ImpersonationContext.GetCurrentContext();

            if (impersonationContext != null)
            {
                var impersonationHeader = new ImpersonationHeader {
                    TargetUsername = impersonationContext.TargetUsername
                };
                MessageHeader header = MessageHeader.CreateHeader(Constants.HeaderName, Constants.Namespace, impersonationHeader);
                request.Headers.Add(header);
            }
            return(null);
        }