当前位置: 首页>>代码示例>>C#>>正文


C# Description.ClientCredentials类代码示例

本文整理汇总了C#中System.ServiceModel.Description.ClientCredentials的典型用法代码示例。如果您正苦于以下问题:C# ClientCredentials类的具体用法?C# ClientCredentials怎么用?C# ClientCredentials使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ClientCredentials类属于System.ServiceModel.Description命名空间,在下文中一共展示了ClientCredentials类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCredentials

 public ClientCredentials GetCredentials(AuthenticationProviderType providerType, string domain, string username, string password)
 {
     var creds = new ClientCredentials();
     switch (providerType)
     {
         case AuthenticationProviderType.Federation:
         case AuthenticationProviderType.LiveId:
             if (string.IsNullOrEmpty(domain))
             {
                 creds.UserName.UserName = username;
                 creds.UserName.Password = password;
             }
             else
             {
                 creds.UserName.UserName = string.Concat(domain, @"\", username);
                 creds.UserName.Password = password;
             }
             break;
         case AuthenticationProviderType.ActiveDirectory:
             creds.Windows.ClientCredential = string.IsNullOrEmpty(domain) ? new NetworkCredential(username, password) : new NetworkCredential(username, password, domain);
             break;
         default:
             break;
     }
     return creds;
 }
开发者ID:pharmadata,项目名称:CrmDeploy,代码行数:26,代码来源:CrmClientCredentialsProvider.cs

示例2: CRMEntityMananger

 public CRMEntityMananger()
 {
     Credentials = new ClientCredentials();
     Credentials.UserName.UserName = "pecs\\crmadmin";
     Credentials.UserName.Password = "Password%%";
     OrganizationUri = new Uri("http://crm.pecs.co.za:5555/PECorporateServices/XRMServices/2011/Organization.svc");
 }
开发者ID:anthonied,项目名称:CRM,代码行数:7,代码来源:CRMEntityMananger.cs

示例3: GetTokenUIAsyncResult

 internal GetTokenUIAsyncResult(Binding binding, IClientChannel channel, ClientCredentials credentials, AsyncCallback callback, object state) : base(callback, state)
 {
     this.credentials = credentials;
     this.proxy = channel;
     this.binding = binding;
     this.CallBegin(true);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:GetTokenUIAsyncResult.cs

示例4: ApplyConfiguration

 protected internal void ApplyConfiguration(ClientCredentials behavior)
 {
     if (behavior == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("behavior");
     }
     PropertyInformationCollection properties = base.ElementInformation.Properties;
     if (properties["windows"].ValueOrigin != PropertyValueOrigin.Default)
     {
         this.Windows.ApplyConfiguration(behavior.Windows);
     }
     if (properties["clientCertificate"].ValueOrigin != PropertyValueOrigin.Default)
     {
         this.ClientCertificate.ApplyConfiguration(behavior.ClientCertificate);
     }
     if (properties["serviceCertificate"].ValueOrigin != PropertyValueOrigin.Default)
     {
         this.ServiceCertificate.ApplyConfiguration(behavior.ServiceCertificate);
     }
     if (properties["issuedToken"].ValueOrigin != PropertyValueOrigin.Default)
     {
         this.IssuedToken.ApplyConfiguration(behavior.IssuedToken);
     }
     if (properties["httpDigest"].ValueOrigin != PropertyValueOrigin.Default)
     {
         this.HttpDigest.ApplyConfiguration(behavior.HttpDigest);
     }
     if (properties["peer"].ValueOrigin != PropertyValueOrigin.Default)
     {
         this.Peer.ApplyConfiguration(behavior.Peer);
     }
     behavior.SupportInteractive = this.SupportInteractive;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:33,代码来源:ClientCredentialsElement.cs

示例5: GetOrgService

        public static IOrganizationService GetOrgService(bool admin = false, string callerId = null, string organization = null)
        {
            ClientCredentials credential = new ClientCredentials();

            if (Globals.OrganizationServiceUrl.Contains("https"))
            {
                credential.Windows.ClientCredential = admin ? new NetworkCredential(Globals.AdminUserName, Globals.AdminPassword, Globals.DomainName) : CredentialCache.DefaultNetworkCredentials;
                credential.UserName.UserName = Globals.DomainName + @"\" + Globals.AdminUserName;
                credential.UserName.Password = Globals.AdminPassword;
            }
            else
            {
                credential.Windows.ClientCredential = admin ? new NetworkCredential(Globals.AdminUserName, Globals.AdminPassword, Globals.DomainName) : CredentialCache.DefaultNetworkCredentials;
            }

            OrganizationServiceProxy orgServiceProxy = new OrganizationServiceProxy(new Uri(Globals.OrganizationServiceUrl), null, credential, null);
            if (!string.IsNullOrEmpty(callerId))
            {
                orgServiceProxy.CallerId = new Guid(callerId);
            }
            return orgServiceProxy;

            ////credential.Windows.ClientCredential = admin ? new NetworkCredential(Globals.AdminUserName, Globals.AdminPassword, Globals.DomainName) : CredentialCache.DefaultNetworkCredentials;
            ////credential.UserName.UserName = Globals.DomainName + @"\" + Globals.AdminUserName;
            ////credential.UserName.Password = Globals.AdminPassword;
            ////OrganizationServiceProxy orgServiceProxy = new OrganizationServiceProxy(new Uri(Globals.OrganizationServiceUrl), null, credential, null);
            ////if (!string.IsNullOrEmpty(callerId))
            ////{
            ////    orgServiceProxy.CallerId = new Guid(callerId);
            ////}
            ////return orgServiceProxy;
        }
开发者ID:volkanytu,项目名称:Portal,代码行数:32,代码来源:MSCRM.cs

示例6: GetCredentials

        private static ClientCredentials GetCredentials(string url, string domain, string username, string password)
        {
            ClientCredentials credentials = new ClientCredentials();

            var config = ServiceConfigurationFactory.CreateConfiguration<IDiscoveryService>(new Uri(url));

            if (config.AuthenticationType == AuthenticationProviderType.ActiveDirectory)
            {
                NetworkCredential nc = CredentialCache.DefaultNetworkCredentials;
                if (!string.IsNullOrEmpty(domain) && !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
                {
                    nc = new System.Net.NetworkCredential(username, password, domain);
                }

                credentials.Windows.ClientCredential = nc;
            }
            else if (config.AuthenticationType == AuthenticationProviderType.Federation
                || config.AuthenticationType == AuthenticationProviderType.LiveId
                || config.AuthenticationType == AuthenticationProviderType.OnlineFederation)
            {
                credentials.UserName.UserName = username;
                credentials.UserName.Password = password;
            }
            else if (config.AuthenticationType == AuthenticationProviderType.None)
            {
            }

            return credentials;
        }
开发者ID:patryksuchowierski,项目名称:my1stgithubrepo,代码行数:29,代码来源:QuickConnection.cs

示例7: InfocardInteractiveChannelInitializer

		public InfocardInteractiveChannelInitializer (
			ClientCredentials credentials,
			Binding binding)
		{
			this.binding = binding;
			this.credentials = credentials;
		}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:InfocardInteractiveChannelInitializer.cs

示例8: ClientCredentials

        protected ClientCredentials(ClientCredentials other)
        {
            if (other == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("other");
            if (other.userName != null)
                this.userName = new UserNamePasswordClientCredential(other.userName);
            if (other.clientCertificate != null)
                this.clientCertificate = new X509CertificateInitiatorClientCredential(other.clientCertificate);
            if (other.serviceCertificate != null)
                this.serviceCertificate = new X509CertificateRecipientClientCredential(other.serviceCertificate);
            if (other.windows != null)
                this.windows = new WindowsClientCredential(other.windows);
            if (other.httpDigest != null)
                this.httpDigest = new HttpDigestClientCredential(other.httpDigest);
            if (other.issuedToken != null)
                this.issuedToken = new IssuedTokenClientCredential(other.issuedToken);
            if (other.peer != null)
                this.peer = new PeerCredential(other.peer);

            this.getInfoCardTokenCallback = other.getInfoCardTokenCallback;
            this.supportInteractive = other.supportInteractive;
            this.securityTokenHandlerCollectionManager = other.securityTokenHandlerCollectionManager;
            this.useIdentityConfiguration = other.useIdentityConfiguration;
            this.isReadOnly = other.isReadOnly;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:25,代码来源:ClientCredentials.cs

示例9: CrmServiceFactory

        public CrmServiceFactory()
        {
            Uri organizationUri = GetOrganizationUri();

            if (string.IsNullOrWhiteSpace(CrmConnectorSection.Instance.UserName))
                throw new CrmException("A value must be supplied for username in the <crmFramework> section in web.config");

            if (string.IsNullOrWhiteSpace(CrmConnectorSection.Instance.Password))
                throw new CrmException("A value must be supplied for password in the <crmFramework> section in web.config");

            if (string.IsNullOrWhiteSpace(CrmConnectorSection.Instance.Domain))
                throw new CrmException("A value must be supplied for domain in the <crmFramework> section in web.config");

            IServiceManagement<IOrganizationService> serviceManagement = ServiceConfigurationFactory.CreateManagement<IOrganizationService>(organizationUri);

            ClientCredentials clientCredentials = new ClientCredentials();
            clientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
            clientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            clientCredentials.UserName.UserName = string.Format("{0}@{1}", CrmConnectorSection.Instance.UserName, CrmConnectorSection.Instance.Domain);
            clientCredentials.UserName.Password = CrmConnectorSection.Instance.Password;
            OrganizationServiceProxy organizationServiceProxy = new OrganizationServiceProxy(
                serviceManagement,
                clientCredentials);
            organizationServiceProxy.EnableProxyTypes();
            _organizationServiceProxy = organizationServiceProxy;
        }
开发者ID:karolikl,项目名称:Epinova.CRMFramework,代码行数:26,代码来源:CrmServiceFactory.cs

示例10: connect

        public bool connect(string serviceURL, string domainName, string userName, string password)
        {
            try
            {

                Uri organizationUri = new Uri(serviceURL);
                Uri homeRealmUri = null;
                ClientCredentials credentials = new ClientCredentials();
                // set default credentials for OrganizationService
                credentials.Windows.ClientCredential = new NetworkCredential(userName, password, domainName);
                // credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
                OrganizationServiceProxy orgProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
                _service = (IOrganizationService)orgProxy;

                //to check connection with CRM
                getAttributeMax("campaign", "exchangerate");

                return true;
            }
            catch (InvalidOperationException)
            {
                throw new connectionException("The URI provided cannot be resolved ( " + serviceURL + " )");
            }
            catch (SecurityNegotiationException)
            {
                throw new connectionException("The authentication failed ! Please check the credentials provided.");
            }
            catch (Exception ex)
            {
                throw new connectionException(ex.Message);
            }
        }
开发者ID:JuustoMestari,项目名称:CRM,代码行数:32,代码来源:ESC_CRM11.cs

示例11: Validate

        public ClaimsPrincipal Validate(string userName, string password)
        {
            var binding = new UserNameWSTrustBinding(SecurityMode.TransportWithMessageCredential);
            var credentials = new ClientCredentials();
            credentials.UserName.UserName = userName;
            credentials.UserName.Password = password;

            GenericXmlSecurityToken genericToken;
            genericToken = WSTrustClient.Issue(
                new EndpointAddress(_address),
                new EndpointAddress(_realm),
                binding,
                credentials) as GenericXmlSecurityToken;

            var config = new SecurityTokenHandlerConfiguration();
            config.AudienceRestriction.AllowedAudienceUris.Add(new Uri(_realm));

            config.CertificateValidationMode = X509CertificateValidationMode.None;
            config.CertificateValidator = X509CertificateValidator.None;

            var registry = new ConfigurationBasedIssuerNameRegistry();
            registry.AddTrustedIssuer(_issuerThumbprint, _address);
            config.IssuerNameRegistry = registry;

            var handler = SecurityTokenHandlerCollection.CreateDefaultSecurityTokenHandlerCollection(config);

            ClaimsPrincipal principal;
            var token = genericToken.ToSecurityToken();
            principal = new ClaimsPrincipal(handler.ValidateToken(token));

            Tracing.Information("Successfully requested token for user via WS-Trust");
            return FederatedAuthentication.FederationConfiguration.IdentityConfiguration.ClaimsAuthenticationManager.Authenticate("ResourceOwnerPasswordValidation", principal);
        }
开发者ID:Excelsior-Charles,项目名称:Thinktecture.AuthorizationServer,代码行数:33,代码来源:WSTrustResourceOwnerCredentialValidation.cs

示例12: BusStopDetails

        public BusStopDetails(ClientCredentials clientCredentials)
        {
            InitializeComponent();
            ActualBusStop = new BusStop();

            busStopService = new BusStopServiceClient();

            busStopSecureService = new BusStopSecureServiceClient();
            busStopSecureService.ClientCredentials.UserName.UserName = clientCredentials.UserName.UserName;
            busStopSecureService.ClientCredentials.UserName.Password = clientCredentials.UserName.Password;

            busStopTypeService = new BusStopTypeServiceClient();
            busStopTypeService.ClientCredentials.UserName.UserName = clientCredentials.UserName.UserName;
            busStopTypeService.ClientCredentials.UserName.Password = clientCredentials.UserName.Password;

            busStopTypeSecureService = new BusStopTypeSecureServiceClient();
            busStopTypeSecureService.ClientCredentials.UserName.UserName = clientCredentials.UserName.UserName;
            busStopTypeSecureService.ClientCredentials.UserName.Password = clientCredentials.UserName.Password;

            BusStopTypeComboBox.ItemsSource = busStopTypeService.GetAll();

            OpenAllTextBoxes();
            SaveButton.IsEnabled = true;
            EditButton.IsEnabled = false;
            DeleteButton.IsEnabled = false;

            IsAddingNewObject = true;
        }
开发者ID:PatrykOlejniczak,项目名称:WPK.TransportSystem,代码行数:28,代码来源:BusStopDetails.xaml.cs

示例13: Connect

        public static OrganizationServiceProxy Connect()
        {
            ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["CRM"];

            if (settings == null)
                throw new ConfigurationException("No CRM Connection String was found.");

            Uri uri = new Uri(settings.ConnectionString);

            ClientCredentials credentials = null;

            string user = ConfigurationManager.AppSettings["User"];
            string password = ConfigurationManager.AppSettings["Password"];

            if (!string.IsNullOrWhiteSpace(user))
            {
                credentials = new ClientCredentials();

                credentials.UserName.UserName = "";
                credentials.UserName.Password = "";
            }

            OrganizationServiceProxy proxy = new OrganizationServiceProxy(uri, null, credentials, null);

            proxy.EnableProxyTypes(typeof(Toyota.Tsusho.CRM.API.Contact).Assembly);

            return proxy;
        }
开发者ID:britehouse,项目名称:toyota-tsusho-new,代码行数:28,代码来源:CRMHelper.cs

示例14: IsAuthenticated

        public async Task<bool> IsAuthenticated(PortalUser user)
        {
            string Url = ConfigurationManager.AppSettings["URL"].ToString();
            string CrmConnectionString = string.Format("Url={0}; Username={1}; Password={2}",
                                                              Url, user.Username, user.Password);
          
            ClientCredentials credential = new ClientCredentials();          
            
            credential.UserName.UserName = user.Username;
            credential.UserName.Password = user.Password;


            CrmConnection crmConnection = CrmConnection.Parse(CrmConnectionString);
            crmConnection.ClientCredentials = credential;
            OrganizationService service = new OrganizationService(crmConnection);

            QueryExpression qe = new QueryExpression("systemuser");
            qe.ColumnSet = new ColumnSet();
            qe.ColumnSet.AddColumn("systemuserid");
            qe.ColumnSet.AddColumn("fullname");
            qe.Criteria = new FilterExpression();
            qe.Criteria.AddCondition("domainname", ConditionOperator.Equal, user.Username);

            EntityCollection collection = service.RetrieveMultiple(qe);

            if (collection.Entities.Count == 0)
            {
                return false;   
            }
            return true;
        }
开发者ID:rexghadaffi,项目名称:TE-System,代码行数:31,代码来源:CrmAuthentication.cs

示例15: lock

        void IChannelCredentials.SetWindowsCredential(string domain, string userName, string password, int impersonationLevel, bool allowNtlm)
        {
            lock (channelBuilderSettings)
            {
                KeyedByTypeCollection<IEndpointBehavior> behaviors = channelBuilderSettings.Behaviors;
                NetworkCredential newCredentials = null;
                if ((!String.IsNullOrEmpty(domain)) || (!String.IsNullOrEmpty(userName)) || (!String.IsNullOrEmpty(password)))
                {
                    if (String.IsNullOrEmpty(userName))
                    {
                        userName = "";
                    }
                    System.ServiceModel.Security.SecurityUtils.PrepareNetworkCredential();
                    newCredentials = new NetworkCredential(userName, password, domain);
                }
                ClientCredentials channelCredentials = behaviors.Find<ClientCredentials>();
                if (channelCredentials == null)
                {
                    channelCredentials = new ClientCredentials();
                    behaviors.Add(channelCredentials);
                }
                channelCredentials.Windows.AllowedImpersonationLevel = (TokenImpersonationLevel)impersonationLevel;

                // To disable AllowNtlm warning.
#pragma warning disable 618
                channelCredentials.Windows.AllowNtlm = allowNtlm;
#pragma warning restore 618

                channelCredentials.Windows.ClientCredential = newCredentials;
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:31,代码来源:ChannelCredentials.cs


注:本文中的System.ServiceModel.Description.ClientCredentials类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。