开发者

Java, LDAP, ADAM - How do I create a container with a forward slash in the name

I am having trouble writing some Java code, which will create a container/folder in ADAM, where the container name and distinughed name contain a forward slash.

e.g.

cn=test/test

dn=CN=test/test,CN=TestStore,DC=MyCompany,DC=COM

LdapContext _ctx = getNewContext(valid_userName, valid_userName, valid_userName);
  // uses InitialLdapContext under the hood 

String containerDN = "dn=CN=test/test,CN=TestStore,DC=MyCompany,DC=COM"
_ctx.createSubcontext(containerDN, attrs); // assume attrs is valid javax.naming.directory.Attributes

I am struggling to escpae the forward slash from the Java String object, and yet allow the InitialLdapContext to create the container with the name.

FRom the ADAM Adsi Edit application, I can create folders with forward slashes, so I presume the pro开发者_开发知识库cess can be done from code as well.

Many thanks in advance ...


Re-reading the JavaDocs API for LDAPContext, and DirContext ... an overloaded method createSubContext() offers:

public DirContext createSubcontext(Name name, Attributes attrs) throws NamingException

the Name interface, concrete class CompositeName handles the escaping/un-escaping of special characters for me ...

many thanks JRL !


From Technet, might be of use:

If the name of an organizational unit contains a forward slash character (/), the system requires an escape character in the form of a backslash () to distinguish between forward slashes that separate elements of the canonical name and the forward slash that is part of the organizational unit name. The canonical name that appears in Active Directory Users and Computers properties pages displays the escape character immediately preceding the forward slash in the name of the organizational unit. For example, if the name of an organizational unit is Promotions/Northeast and the name of the domain is Reskit.com, the canonical name is displayed as Reskit.com/Promotions/Northeast

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜