Add a user to a group in Active Directory: LdapErr: DSID-0C090A85

Discussion in 'Java' started by gimme_this_gimme_that@yahoo.com, Mar 24, 2009.

  1. Guest

    Running this code results in a message that says (the names have been
    obfuscated but the structure of the names is right):

    Problem adding member: javax.naming.InvalidNameException:
    CN=MyGroup,OU=VAP,OU=MyOU ,OU=Rights,OU=Groups,OU=Americas,DC=na,DC=msds,DC=rhi,DC=com:

    [LDAP: error code 34 - 00000057: LdapErr: DSID-0C090A85, comment:
    Error in attri
    bute conversion operation, data 0, vece ];

    I know the name exists and I can add members using VBScript.

    Here is the JSP - does anyone see what I'm doing wrong?

    Thanks.

    <%@ page language="java" import="import
    java.util.Hashtable,javax.naming.directory.*,javax.naming.*" %>

    <%!
    public void doit()
    {

    Hashtable env = new Hashtable();
    String adminName = "CN=myaccount,OU=Blah Blah
    Accounts,OU=Blah,DC=na,DC=msds,DC=rhi,DC=com";
    String adminPassword = "mypassword";
    String userName = "CN=Doe\\\\, John,OU=Users,OU=Field ,OU=Field
    Accounts,OU=Some Field Accounts,DC=na,DC=msds,DC=rhi,DC=com";
    String groupName =
    "CN=MyGroup,OU=VAP,OU=MyOU ,OU=Rights,OU=Groups,OU=Americas,DC=na,DC=msds,DC=rhi,DC=com";


    env.put
    (Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.SECURITY_AUTHENTICATION,"simple");
    env.put(Context.SECURITY_PRINCIPAL,adminName);
    env.put(Context.SECURITY_CREDENTIALS,adminPassword);
    env.put(Context.PROVIDER_URL, "ldap://myldaphost:myldapport");

    try {
    InitialDirContext ctx = new InitialDirContext(env);
    ModificationItem[] mods = new ModificationItem[1];
    mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE,
    new BasicAttribute("member", userName));
    ctx.modifyAttributes(groupName, mods);
    ctx.close();
    System.out.println("Added " + userName + " to " +
    groupName);
    }
    catch (NamingException e) {
    System.err.println("Problem adding member: " + e);
    }
    }
    %>
    <% doit(); %>
    test
     
    , Mar 24, 2009
    #1
    1. Advertising

  2. Nigel Wade Guest

    wrote:

    > Running this code results in a message that says (the names have been
    > obfuscated but the structure of the names is right):
    >
    > Problem adding member: javax.naming.InvalidNameException:
    >

    CN=MyGroup,OU=VAP,OU=MyOU ,OU=Rights,OU=Groups,OU=Americas,DC=na,DC=msds,DC=rhi,DC=com:
    >
    > [LDAP: error code 34 - 00000057: LdapErr: DSID-0C090A85, comment:
    > Error in attri
    > bute conversion operation, data 0, vece ];
    >
    > I know the name exists and I can add members using VBScript.


    Well, LDAP disagrees with you.

    Is the space meant to be in the OU=MyOU ? If it is it needs to be escaped with a
    backslash (at least that's what my LDAP book says, I've never ever used that
    particular naming).

    --
    Nigel Wade
     
    Nigel Wade, Mar 24, 2009
    #2
    1. Advertising

  3. Guest

    Thanks Nigel.

    Escaping spaces is a good tip that might come in handy.

    It turns out the space in the group name was something I added when I
    attempted to obfuscate the OU.

    > Nigel Wade
     
    , Mar 24, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QW5kZXJzQmo=?=

    List members of a active directory group

    =?Utf-8?B?QW5kZXJzQmo=?=, Jun 10, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    586
    =?Utf-8?B?QW5kZXJzQmo=?=
    Jun 10, 2004
  2. zieg
    Replies:
    0
    Views:
    2,027
  3. moi
    Replies:
    2
    Views:
    2,864
    Marc Scheuner
    Apr 22, 2006
  4. Dirk Hagemann
    Replies:
    3
    Views:
    515
    Dirk Hagemann
    May 4, 2007
  5. Patrick Olurotimi Ige

    problem getting User Group Memebership in Active Directory

    Patrick Olurotimi Ige, May 9, 2005, in forum: ASP .Net Security
    Replies:
    2
    Views:
    245
    Patrick Olurotimi Ige
    May 10, 2005
Loading...

Share This Page