我试过了
java.util.Hashtable;
import java.util.Properties;
import java.util.jar.Attributes;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.BasicAttributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
public class Main{
public static void main(String[] args) {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost:10389");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL,"uid=admin,ou=system"); // specify the username
env.put(Context.SECURITY_CREDENTIALS,"secret");// specify the password
// TODO code application logic here
// entry's DN
String entryDN = "cn=myadmins,ou=groups,ou=system";
// entry's attributes
Attribute cn = new BasicAttribute("cn", "myadmins");
Attribute oc = new BasicAttribute("objectClass");
oc.add("top");
oc.add("groupOfUniqueNames");
DirContext ctx = null;
try {
// get a handle to an Initial DirContext
ctx = new InitialDirContext(env);
// build the entry
BasicAttributes entry = new BasicAttributes();
entry.put(cn);
entry.put(oc);
// Add the entry
ctx.createSubcontext(entryDN, entry);
// System.out.println( "AddUser: added entry " + entryDN + ".");
} catch (NamingException e) {
System.err.println("AddUser: error adding entry." + e);
}
}
}
我正在研究 DS 的示例默认架构。
但我明白了
Required attributes [uniqueMember(2.5.4.50)] not found within entry cn=myadmins,ou=groups,ou=system]; remaining name 'cn=myadmins,ou=groups,ou=system'
我查看了其他组条目,它具有uniqueMember
带值的属性:
0.9.2342.19200300.100.1.1=admin,2.5.4.11=system
如何为我的新组指定 uniqueMember 属性的值,
我必须承认包含点的数字对我来说有点复杂。
谢谢