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

StackOverflow https://stackoverflow.com/questions/2146684

  •  23-09-2019
  •  | 
  •  

문제

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 ...

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top