我的下面的代码示例工作正常,但我想将我的客户端凭据添加到web.config文件(即连接字符串内)。使用连接字符串
我试过但没有运气。任何人都可以帮忙吗?
protected void Page_Load(object sender, EventArgs e)
{
// Organisation service URL
var organizationUri = new Uri(ConfigurationManager.ConnectionStrings["CrmConnectionStr"].ConnectionString);
//Client credentials
var credentials = new ClientCredentials();
credentials.UserName.UserName = @"domain\username";
credentials.UserName.Password = "password";
// Use the Microsoft Dynamics CRM Online connection string from the web.config file named "CrmConnectionStr".
using (OrganizationServiceProxy _service = new OrganizationServiceProxy(organizationUri, null, credentials, null))
{
Response.Write("Connected");
}
}
Web.config文件
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="CrmConnectionStr" connectionString="https://test.domain.com/XRMServices/2011/Organization.svc" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
</configuration>
我不熟悉动力学,所以请原谅我,如果这是关闭的。你有没有退房? http://msdn.microsoft.com/en-us/library/ff681567.aspx。看起来您可能可以添加它。向下滚动到“以下示例显示使用Active Directory身份验证的连接字符串:”部分 – RandomWebGuy
连接字符串是数据库连接字符串。其他的应用程序设置 - 研究命名空间而不是 –
这不是连接字符串。你的字符串是web服务的URL。连接字符串是可用于连接到RDMS(数据库系统,如SQL Server或Oracle)的字符串 – mortb