简体   繁体   English

连接字符串中带有特殊字符的密码

[英]Password with special characters in connectionString

I need to connect to my Dynamics CRM 365 on premise instance from an ASP NET application.我需要从 ASP NET 应用程序连接到我的 Dynamics CRM 365 本地实例。 My problem is that the account for connection has a password like: T,jL4O&vc%t;30我的问题是连接帐户的密码如下:T,jL4O&vc%t;30

  <connectionStrings>
    <add name="CRM365" connectionString="AuthType=AD;Url=http://crm.xxx.com/CRM365; Domain=test; Username=test; Password=T,jL4O&vc%t;30" />
  </connectionStrings>

I have the following error: vc is not defined我有以下错误: vc 未定义

Please help.请帮忙。 Thanks谢谢

In this example I see two things:在这个例子中,我看到了两件事:

  1. A & in xml should be escaped with &amp; A & in xml 应该用&amp;转义(Good explanation in this answer ) 这个答案很好的解释)
  2. A ;一个; in a connection string, you should wrap the password in single quotes在连接字符串中,您应该将密码用单引号引起来

So this should work for you:所以这应该适合你:

<connectionStrings>
    <add name="CRM365" connectionString="AuthType=AD;Url=http://crm.xxx.com/CRM365; Domain=test; Username=test; Password='T,jL4O&amp;vc%t;30'" />
</connectionStrings>

Edit (just tried it for myself):编辑(只是为自己尝试过):
Additionally, another variant is to use escaped double quotes:此外,另一种变体是使用转义的双引号:

<connectionStrings>
    <add name="CRM365" connectionString="AuthType=AD;Url=http://crm.xxx.com/CRM365; Domain=test; Username=test; Password=&quot;T,jL4O&amp;vc%t;30&quot;" />
</connectionStrings>

Summary:概括:
Use either password='T,jL4O&amp;vc%t;30';使用任password='T,jL4O&amp;vc%t;30'; or password=&quot;T,jL4O&amp;vc%t;30&quot;;password=&quot;T,jL4O&amp;vc%t;30&quot;;

I think you can set random password for connection string.我认为您可以为连接字符串设置随机密码。 Please remove ';'请删除 ';' from password if ';'从密码 if ';' occurs then connectionstring will interpret as password completed发生然后连接字符串将解释为密码完成

<connectionStrings>
<add name="CRM365" connectionString="AuthType=AD;Url=http://crm.xxx.com/CRM365; Domain=test; Username=test; Password=T,jL4O&vc%t30" />

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

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