Esempio n. 1
0
        public ImpersonationContext(string targetUsername)
        {
            if (targetUsername == null)
                throw new ArgumentNullException("targetUsername");

            TargetUsername = targetUsername;
            current = this;
        }
Esempio n. 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);
        }