Active Directory:此处是否存在无效字符转义以及如何处理
- 作者: 啊曹呸呸
- 来源: 51数据库
- 2022-10-28
问题描述
我已经构建了一个过程,可以通过 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 ***** 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.
- C#通过fleck实现wss协议的WebSocket多人Web实时聊天(附源码)
- 团队城市未满足要求:MSBuildTools12.0_x86_Path 存在
- 使用 MSBuild.exe 在发布模式下构建 C# 解决方案
- 当我发布 Web 应用程序时,AfterPublish 脚本不运行
- 构建时 T4 转换的产品仅在下一个构建中使用
- ASP.NET Core Application (.NET Framework) for Windows x64 only error in project.assets.json
- 新的 .csproj 格式 - 如何将整个目录指定为“链接文件"到子目录?
- 如何将条件编译符号(DefineConstants)传递给 msbuild
- MSBuild 支持 Visual Studio 2017 RTM 中的 T4 模板
- NuGet 包还原找不到包,没有源
