views:

229

answers:

2

Hi:

Is it possible to create a new user in AD rom Java via JNDI?

I tried via trusty Google but nothing came up - maybe I was googling using the wrong terminology (JNDI Active Directory Create User).

Any tips will be create appreciated.

Current status: I have connected to AD via my Java code and can change attributes of existing AD accounts; next I would like to be able to create AD users from Java/JNDI.

Thanks!

A: 

From http://forums.sun.com/thread.jspa?threadID=581444&messageID=3313188

public void addUserToGroup(LdapContext ctx, String userDN, String groupDN)
    throws NamingException {
    ModificationItem[] mods = new ModificationItem[1];
    mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE,
            new BasicAttribute("member", userDN));

    ctx.modifyAttributes(groupDN, mods);
}

public void removeUserFromGroup(LdapContext ctx, String userDN,
    String groupDN) throws NamingException {
    ModificationItem[] mods = new ModificationItem[1];
    mods[0] = new ModificationItem(DirContext.REMOVE_ATTRIBUTE,
            new BasicAttribute("member", userDN));

    ctx.modifyAttributes(groupDN, mods);
}
Romain Hippeau
A: 

how can i write "create account" java program. i make a project ı have to add create account class with password and nickname. thank you

Hüseyin
Try this: http://forums.sun.com/thread.jspa?threadID=582103Make sure your account has the correct privileges to create an AD account and you are using LDAPS
WhereIsTheBubble