Asp.net web api CRM Dynamics 2016内部部署Web API上的客户端凭据授予
我正在尝试调用CRM Dynamics On Premise 2016 Web API。 我使用OAuth配置了授权代码流,它正在工作。但是,我需要设置客户端凭据流,因为许多应用程序都在后台运行,并且无法使用登录屏幕提示它们。 因为,这是前提,我们没有Azure广告Asp.net web api CRM Dynamics 2016内部部署Web API上的客户端凭据授予,asp.net-web-api,dynamics-crm,microsoft-dynamics,Asp.net Web Api,Dynamics Crm,Microsoft Dynamics,我正在尝试调用CRM Dynamics On Premise 2016 Web API。 我使用OAuth配置了授权代码流,它正在工作。但是,我需要设置客户端凭据流,因为许多应用程序都在后台运行,并且无法使用登录屏幕提示它们。 因为,这是前提,我们没有Azure广告 我们去哪里注册我们的申请 是否有其他方式访问内部部署动态CRM的Web API(例如用户ID、密码等) Xrm api可以通过客户端凭据访问,无需任何特殊设置(无论是在prem上还是在线设置)-您只需使用适当的权限设置S2S用户,就
Xrm api可以通过客户端凭据访问,无需任何特殊设置(无论是在prem上还是在线设置)-您只需使用适当的权限设置S2S用户,就可以像这样登录他:
static void InContext(Action<IOrganizationService> callback, Org org)
{
var credentials = new ClientCredentials();
if (!org.IsLocal)
{
credentials.UserName.UserName = org.UserName;
credentials.UserName.Password = org.Password;
}
else
{
credentials.Windows.ClientCredential = new NetworkCredential(org.UserName, org.Password);
}
using (var serviceProxy =
new OrganizationServiceProxy(new Uri(org.OrganizationServiceUri),
null, credentials
, null))
{
callback.Invoke(serviceProxy);
}
}
public class Org
{
public string UserName { get; set; }
public string Password { get; set; }
public string OrganizationServiceUri { get; set; }
public bool IsLocal { get; set; }
public Org()
{
}
public Org(bool isLocal, string userName, string password, string organizationServiceUri)
{
IsLocal = isLocal;
UserName = userName;
Password = password;
OrganizationServiceUri = organizationServiceUri;
DiscoveryServiceUri = discoveryServiceUri;
}
}
Xrm api可以通过客户端凭据访问,无需任何特殊设置(无论是在prem上还是在线设置)-您只需使用适当的权限设置S2S用户,就可以像这样登录他:
static void InContext(Action<IOrganizationService> callback, Org org)
{
var credentials = new ClientCredentials();
if (!org.IsLocal)
{
credentials.UserName.UserName = org.UserName;
credentials.UserName.Password = org.Password;
}
else
{
credentials.Windows.ClientCredential = new NetworkCredential(org.UserName, org.Password);
}
using (var serviceProxy =
new OrganizationServiceProxy(new Uri(org.OrganizationServiceUri),
null, credentials
, null))
{
callback.Invoke(serviceProxy);
}
}
public class Org
{
public string UserName { get; set; }
public string Password { get; set; }
public string OrganizationServiceUri { get; set; }
public bool IsLocal { get; set; }
public Org()
{
}
public Org(bool isLocal, string userName, string password, string organizationServiceUri)
{
IsLocal = isLocal;
UserName = userName;
Password = password;
OrganizationServiceUri = organizationServiceUri;
DiscoveryServiceUri = discoveryServiceUri;
}
}
我没有做过,但是你可能想看看OAuth2…我没有做过,但是你可能想看看OAuth2。。。