2017-10-02 5 views
0

タイトルに記載したとおり、私はSecurityTokenResponeに問題があります。当社の生産CRMのADFSを構成しているし、テストCRM」はdoesnのためSecurityTokenResponeがnullです

IServiceManagement<IOrganizationService> serviceManagement = ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri("https://SERVICE_URI")); 
AuthenticationCredentials authCreds = new AuthenticationCredentials(); 
authCreds.ClientCredentials.UserName.UserName = userName; 
authCreds.ClientCredentials.UserName.Password = password; 
AuthenticationCredentials tokenCreds = serviceManagement.Authenticate(authCreds); 
SecurityTokenResponse securityToken = tokenCredentials.SecurityTokenResponse; 

私は生産CRMへの呼び出しを行うと

...私はSecurityTokenResponeを取得するが、私は我々のテストCRM SecurityTokenResponeへの呼び出しがnull作るときはこれですt?

はいの場合、何らかの理由でバイパスすることはできますか?(私たちのテストCRMはインターネットに公開できないドメインにあります)

ありがとうございました:)

答えて

1

私はあなたのテストのCRMにあなたがADFSせずに単なるADログインを使用していることを前提としています。はいの場合、ここにセキュリティトークンがないため、セキュリティトークンを取得できません。組織サービスを取得するには、次のようにしてください:

ClientCredentials clientCreds = new ClientCredentials(); 
clientCreds.Windows.ClientCredential.UserName = "username"; 
clientCreds.Windows.ClientCredential.Password = "pass"; 
clientCreds.Windows.ClientCredential.Domain = "domain"; 
IServiceConfiguration<IOrganizationService> orgConfigInfo = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(new Uri("http://yourcrmserver/CRO/XRMServices/2011/Organization.svc")); 
OrganizationServiceProxy orgserv = new OrganizationServiceProxy(orgConfigInfo, clientCreds); 
+0

はい、テストCRMがインストールされているサーバーにADFSはありません。私たちはDynamcis CRM 365を使用していますので、 'CrmServiceClient'を使ってCRMに接続します。どうも :) – Genato