简体   繁体   English

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

[英]Getting group attributes for group name with special characters in Active Directory

I have a group name which contains special characters. 我有一个包含特殊字符的组名。

CN=IN&T DC Gebnn/Dohn,OU=ABGroups,OU=Hammers,DC=MyCompany,DC=int

I am trying to get the attributes of this group using the following code: 我正在尝试使用以下代码获取该组的属性:

String lstrFullGpName = CN=IN&T DC Gebnn/Dohn,OU=ABGroups,OU=Hammers,DC=MyCompany,DC=int;
Attributes groupAttributes = actxDir.getAttributes(lstrFullGpName);

This throws the following error: 这将引发以下错误:

Exception in thread "main" javax.naming.NamingException: [LDAP: error code 1 - 000020D6: SvcErr: DSID-031006CC, problem 5012 (DIR_ERROR), data 0 ]; 线程“主”中的异常javax.naming.NamingException:[LDAP:错误代码1-000020D6:SvcErr:DSID-031006CC,问题5012(DIR_ERROR),数据0]; remaining name ' CN=IN&T DC Gebnn/Dohn,OU=ABGroups,OU=Hammers,DC=MyCompany,DC=int' 其余名称'CN = IN&T DC Gebnn / Dohn,OU = ABGroups,OU = Hammers,DC = MyCompany,DC = int'
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3081) 在com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3081)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2987) 在com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2987)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2794) 在com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2794)
at com.sun.jndi.ldap.LdapCtx.c_lookup(LdapCtx.java:1011) 在com.sun.jndi.ldap.LdapCtx.c_lookup(LdapCtx.java:1011)
at com.sun.jndi.toolkit.ctx.ComponentContext.c_resolveIntermediate_nns(ComponentContext.java:152) 在com.sun.jndi.toolkit.ctx.ComponentContext.c_resolveIntermediate_nns(ComponentContext.java:152)
at com.sun.jndi.toolkit.ctx.AtomicContext.c_resolveIntermediate_nns(AtomicContext.java:342) 在com.sun.jndi.toolkit.ctx.AtomicContext.c_resolveIntermediate_nns(AtomicContext.java:342)
at com.sun.jndi.toolkit.ctx.ComponentContext.p_resolveIntermediate(ComponentContext.java:381) 在com.sun.jndi.toolkit.ctx.ComponentContext.p_resolveIntermediate(ComponentContext.java:381)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(ComponentDirContext.java:205) 在com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(ComponentDirContext.java:205)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:121) 在com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:121)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:109) 在com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:109)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:99) 在com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:99)
at LDAPApp.main(LDAPApp.java:68) 在LDAPApp.main(LDAPApp.java:68)

I tried escaping the special characters, but that did not work. 我尝试转义特殊字符,但这没有用。 Any idea why this error could be occurring? 知道为什么会发生此错误吗?

This is a known JNDI restriction: 这是一个已知的JNDI限制:

"If the LDAP entry's name contains [a forward slash], then you need to escape it (using the backslash character ('\\'))." “如果LDAP条目的名称包含[正斜杠],则需要对其进行转义(使用反斜杠字符('\\'))。”

http://docs.oracle.com/javase/tutorial/jndi/ldap/jndi.html http://docs.oracle.com/javase/tutorial/jndi/ldap/jndi.html

Ie instead of Java String "/" , one must use "\\\\/" in String constants, resp. 即,代替Java字符串"/" ,必须分别在字符串常量中使用"\\\\/" escape Strings like this 这样的转义字符串

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

I was finally able to find a solution to this problem. 我终于能够找到解决该问题的方法。 Issues was with the DC in the user name. 用户名中的DC出现问题。

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

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