简体   繁体   English

带有Dynamics CRM API的ASP.NET需要Active Directory身份验证-如何实现?

[英]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. 我正在编写一个Web应用程序,该应用程序需要与我们内部的Dynamics CRM服务器API进行交互。 I'm using the CRM SDK 1.1 in Visual Studio. 我在Visual Studio中使用CRM SDK 1.1。 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. 问题是,Web应用程序托管在远程服务器上,并且显然必须在两个级别上通过CRM进行身份验证-通过API提供的登录信息,也可以通过Active Directory。

It is CRM 2011, and is set up in Internet Facing Deployment (IFD) mode, using Claims Based Authentication. 它是CRM 2011,并使用基于声明的身份验证以Internet面向部署(IFD)模式设置。

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? 目前我对Active Directory知之甚少-问题是,如何通过远程Web服务器在CRM服务器上的AD进行身份验证,以便可以与API进行交互? I don't even know what to google for that. 我什至不知道该用Google做什么。 :) :)

Here is described how to pass authentication in case of IFD deployment with claims-based authentication. 在此描述了在IFD部署中使用基于声明的身份验证的情况下如何通过身份验证。

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();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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