0

I tried

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);  
            }  
         }  
    }  

Iam working on DS's example default schema.

But i get

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'

i looked at other group entry, it has uniqueMember attribute with value:

0.9.2342.19200300.100.1.1=admin,2.5.4.11=system

How can i specify the uniqueMember attribute's value for my new group,

i must confess the number containing dots is a little complicated to me.

Thanks

merveotesi
  • 2,145
  • 15
  • 53
  • 84

1 Answers1

1

The uniqueMember attribute has DN syntax. This means a distinguished name must be used as a value, not a relative distinguished name (or component of a distinguished name). A distinguished name is analogous to a fully-qualified pathname on a filesystem.

Think of the uniqueMember attribute value as a "pointer" to a distinguished name which is a member of the group.

Update:

The the number containing dots is an OID. Attributes, controls, and other things in LDAP use OIDs, for example, an attribute like cn has an OID associated with it that serves to uniquely identify it in the schema.

Terry Gardner
  • 10,957
  • 2
  • 28
  • 38
  • I think i have to specify one uniqueMember while defining new group. Thus how can i specify it? Do i have to take some parameters into account when specifying uniqueMember? – merveotesi Aug 08 '12 at 06:36
  • The `uniqueMember` is the distinguished name of an admin, if the name of the group is any indication. – Terry Gardner Aug 08 '12 at 10:13