Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Client"/> class.
        /// </summary>
        /// <param name="targetUri">Target <see cref="T:System.Uri" /></param>
        /// <param name="domain">Optional domain</param>
        /// <param name="userName">Optional username</param>
        /// <param name="password">Optional password</param>
        public Client(Uri targetUri, String userName, String password)
        {
            mTargetUri = targetUri;

            mClient = new CoreServiceClient(ClientConfiguration.ClientHttpBinding,
                                            new EndpointAddress(ClientConfiguration.ClientHttpUri(targetUri)));

            if (!String.IsNullOrEmpty(userName) && !String.IsNullOrEmpty(password))
            {
                mClient.ClientCredentials.UserName.UserName = userName;
                mClient.ClientCredentials.UserName.Password = password;

                mClient.ChannelFactory.Credentials.UserName.UserName = userName;
                mClient.ChannelFactory.Credentials.UserName.Password = password;
            }
        }