Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 获取Active Directory中具有特殊字符的组名的组属性_Java_Active Directory_Attributes_Jndi - Fatal编程技术网

Java 获取Active Directory中具有特殊字符的组名的组属性

Java 获取Active Directory中具有特殊字符的组名的组属性,java,active-directory,attributes,jndi,Java,Active Directory,Attributes,Jndi,我有一个包含特殊字符的组名 CN=IN&T DC Gebnn/Dohn,OU=ABGroups,OU=Hammers,DC=MyCompany,DC=int 我正在尝试使用以下代码获取此组的属性: String lstrFullGpName = CN=IN&T DC Gebnn/Dohn,OU=ABGroups,OU=Hammers,DC=MyCompany,DC=int; Attributes groupAttributes = actxDir.getAttributes(l

我有一个包含特殊字符的组名

CN=IN&T DC Gebnn/Dohn,OU=ABGroups,OU=Hammers,DC=MyCompany,DC=int
我正在尝试使用以下代码获取此组的属性:

String lstrFullGpName = CN=IN&T DC Gebnn/Dohn,OU=ABGroups,OU=Hammers,DC=MyCompany,DC=int;
Attributes groupAttributes = actxDir.getAttributes(lstrFullGpName);
这会引发以下错误:

线程“main”javax.naming.NamingException中出现异常:[LDAP:错误 代码1-000020D6:SvcErr:DSID-031006CC,问题5012(方向错误), 数据0];剩余名称'CN=IN&T DC Gebnn/Dohn,OU=ABGroups,OU=Hammers,DC=MyCompany,DC=int'
位于com.sun.jndi.ldap.LdapCtx.maperrocode(LdapCtx.java:3081)
位于com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2987)
位于com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2794)
在com.sun.jndi.ldap.LdapCtx.c_查找(LdapCtx.java:1011)
在com.sun.jndi.toolkit.ctx.ComponentContext.c_resolveIntermediate_nns(ComponentContext.java:152)
在com.sun.jndi.toolkit.ctx.AtomicContext.c_resolveIntermediate_nns(AtomicContext.java:342)
在com.sun.jndi.toolkit.ctx.ComponentContext.p_resolveIntermediate(ComponentContext.java:381)
在com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(ComponentDirContext.java:205)上
位于com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:121)
位于com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:109)
位于com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:99)
位于LDAPApp.main(LDAPApp.java:68)


我试着避开那些特殊的角色,但没有成功。知道为什么会发生这个错误吗?

我终于找到了解决这个问题的方法。用户名中的DC存在问题。

这是已知的JNDI限制:

“如果LDAP条目的名称包含[正斜杠],则需要 转义它(使用反斜杠字符(“\”)。“

也就是说,在字符串常量中必须使用
“\\/”
,而不是Java字符串
“/”
。像这样的转义字符串

distinguishedName = distinguishedName.replace("/", "\\/")

真奇怪。下面是说明:错误\u DS\u缺少\u SUPREF 8406(0x20D6)没有为目录服务配置高级引用。因此,目录服务无法向此林之外的对象发出引用。我猜“/”是您的问题吗?为什么,你是如何逃离DC来解决这个问题的?