我已经构建了一个过程,可以通过 SSIS 中的 C# 脚本组件从活动目录中提取数据.此数据需要加载到 SQL Server 中.我遇到了 DistinguishedName (DN) 和 CanonicalName (CN) 包含双引号 (") 和反斜杠 () 转义字符的问题(请参阅下面的网络链接).
I have built a process to extract data from active directory via a C# script component in SSIS. This data needs to be loaded into SQL Server. I am running into problems where the DistinguishedName (DN) and CanonicalName (CN) contain the double quote (") and backslash () escape characters (see weblink below).
https://social.technet.microsoft.com/wiki/contents/articles/5312.active-directory-characters-to-escape.aspx
据我所知,所有转义字符都应该有一个前导反斜杠 ().这个对吗?我之所以这么问是因为我发现我发现的情况并非如此,因此我无法删除这些转义字符,这导致 SSIS 导入失败,并显示无法分别找到 DN 和 CN 的列分隔符的错误.注意:我在 SSIS 连接管理器中将双引号 (") 设置为列分隔符.有没有办法在代码中处理这个问题,或者我需要让 AD 管理员修复它?
From what I can tell, all escape characters should have a leading backslash (). Is this correct? I am asking because it appears that I have found instances where this is not true and so I am unable to remove these escape characters, which is causing SSIS import to fail with the error that it cannot find the column delimiter for DN and CN respectively. Note: I have set the double quote (") as a column delimiter in the SSIS connection manager. Is there a way to handle this in code or do I need to have the AD admin fix it?
string strDistinguishedName = objConverter.ConvertToString(searchResult, "distinguishedName").Replace(""","").Replace("\"","");
Input1: "CN=SomethingHere "Got Rocks\" OtherTextHere,OU=Blah,OU=Bleh,DC=jweezy,DC=com"
Output1: "CN=SomethingHere "Got Rocks OtherTextHere,OU=Blah,OU=Bleh,DC=jweezy,DC=com"
Input2: "CN=SomethingHere2 "Got Gravel" OtherTextHere2,OU=Blah2,OU=Bleh,DC=jweezy,DC=com"
Output2: "CN=SomethingHere2 "Got Gravel" OtherTextHere2,OU=Blah2,OU=Bleh,DC=jweezy,DC=com"
问题似乎是缺少转义符导致的,所以我认为输入应该如下:
The problem seems to be caused by the lack of escape character, so I believe the inputs should be as follows:
Input1: "CN=SomethingHere "Got Rocks" OtherTextHere,OU=Blah,OU=Bleh,DC=jweezy,DC=com"
Input2: "CN=SomethingHere2 "Got Gravel" OtherTextHere2,OU=Blah2,OU=Bleh,DC=jweezy,DC=com"
当他们说双引号需要转义时,他们指的是引号字符:http://www.fileformat.info/info/unicode/char/22/index.htm
When they say that double quotes need to be escaped, they mean the Quotation Mark character: http://www.fileformat.info/info/unicode/char/22/index.htm
在这种情况下:
Input1: "CN=SomethingHere "Got Rocks\" OtherTextHere,OU=Blah,OU=Bleh,DC=jweezy,DC=com"
您看到的未转义字符 () 不同.这是左双引号:http://www.fileformat.info/info/unicode/char/201C/index.htm
The character you are seeing not escaped ("
) is different. It's the Left Double Quotation Mark: http://www.fileformat.info/info/unicode/char/201C/index.htm
这对 AD 没有特殊意义,因此不需要转义.
That has no special meaning to AD and so does not need to be escaped.
但是这个:
Input2: "CN=SomethingHere2 "Got Gravel" OtherTextHere2,OU=Blah2,OU=Bleh,DC=jweezy,DC=com"
如果你完全按原样复制和粘贴,那么我无法发表评论.Gravel"一词后的引用应该被转义.刚才我尝试重命名一个帐户并添加引号,它在DN中自动转义.
If you copy and pasted that exactly as it is, then I can't comment. The quote after the word "Gravel" should be escaped. Just now, I tried to rename an account and add a quote, and it automatically escaped it in the DN.
这篇关于Active Directory:此处是否存在无效字符转义以及如何处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!