Question

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 process can be done from code as well.

Many thanks in advance ...

Was it helpful?

Solution

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 !

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow