简体   繁体   中英

ASP.NET with Dynamics CRM API requires Active Directory authentication - how is this achieved?

I'm writing a web app which needs to interact with our in-house Dynamics CRM server API. I'm using the CRM SDK 1.1 in Visual Studio. Problem is, the web app is hosted on a remote server, and apparently must authenticate with CRM on two levels - via the login supplied via the API, and also via Active Directory.

It is CRM 2011, and is set up in Internet Facing Deployment (IFD) mode, using Claims Based Authentication.

I know little of Active Directory at this stage - so the question is, how do I authenticate with AD on the CRM server, from a remote web server , so I can interact with the API? I don't even know what to google for that. :)

Here is described how to pass authentication in case of IFD deployment with claims-based authentication.

Uri organizationUriIFD = new Uri("https://[server]:[port]/XRMServices/2011/Organization.svc");

ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = "username";
credentials.UserName.Password = "password";

IServiceConfiguration<IOrganizationService> config = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(organizationUriIFD);

using (Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(config, credentials))
{
 // This statement is required to enable early-bound type support.
 _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

 IOrganizationService _service = (IOrganizationService)_serviceProxy;

 WhoAmIResponse response = (WhoAmIResponse)_service.Execute(new WhoAmIRequest());
 Console.WriteLine(response.UserId.ToString());

 Console.ReadLine();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM