javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: ...

Hello,

thats an image of my w2k active directory ldap tree:

http://img248.imageshack.us/img248/918/adwn6.gif

running the bottom code from Adler_Steven which i chnaged with my data i get this error message:

Problem resetting password: javax.naming.NameNotFoundException: [LDAP: error

code 32 - 0000208D: NameErr: DSID-031001C9, problem 2001 (NO_OBJECT), data 0, best match of:

'DC=bodensee,DC=de'

As you can see from my ldap tree screenshot the User DN DOES EXIST:

"CN=verena bit,OU=Lehrer,OU=ASR,DC=bodensee,DC=de"

So why does it not find this name? the User DN is properly written!

import javax.naming.directory.*;

import java.util.Hashtable;

import javax.naming.*;

import javax.naming.ldap.*;

import java.io.UnsupportedEncodingException;

publicclass setPass

{

publicstaticvoid main (String[] args)

{

Hashtable env =new Hashtable();

String adminName ="CN=administrator,CN=Users,DC=bodensee,DC=de";

String adminPassword ="test";

String userName ="CN=verena bit,OU=Lehrer,OU=ASR,DC=bodensee,DC=de";

String newPassword ="123";

//Access the keystore, this is where the Root CA public key cert was installed

//Could also do this via command line java -Djavax.net.ssl.trustStore....

String keystore ="C:/Programme/Java/jre1.6.0_01/lib/security/ZertifikatBerlin";

System.setProperty("javax.net.ssl.trustStore",keystore);

env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");

//set security credentials, note using simple cleartext authentication

env.put(Context.SECURITY_AUTHENTICATION,"simple");

env.put(Context.SECURITY_PRINCIPAL,adminName);

env.put(Context.SECURITY_CREDENTIALS,adminPassword);

//specify use of ssl

env.put(Context.SECURITY_PROTOCOL,"ssl");

//connect to my domain controller

String ldapURL ="ldaps://rhein:636/dc=bodensee,dc=de";

env.put(Context.PROVIDER_URL,ldapURL);

try{

// Create the initial directory context

LdapContext ctx =new InitialLdapContext(env,null);

//set password is a ldap modfy operation

ModificationItem[] mods =new ModificationItem[1];

//Replace the "unicdodePwd" attribute with a new value

//Password must be both Unicode and a quoted string

String newQuotedPassword ="\"" + newPassword +"\"";

byte[] newUnicodePassword = newQuotedPassword.getBytes("UTF-16LE");

mods[0] =new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("unicodePwd", newUnicodePassword));

// Perform the update

ctx.modifyAttributes(userName, mods);

System.out.println("Reset Password for: " + userName);

ctx.close();

}

catch (NamingException e){

System.out.println("Problem resetting password: " + e);

}

catch (UnsupportedEncodingException e){

System.out.println("Problem encoding password: " + e);

}

}

}

best match of:

'DC=bodensee,DC=de'

As you can see the best match is the Base DN the Entry point of the directory so something must be wrong with the RDN of the user "cn=verena bit" BUT WHAT?

This exception is thrown when a component of the name cannot be resolved because it is not bound.

So my user "cn=verena bit" is not bound? BUT its your code and i havent seen something like binding the user whose password gets deleted in your code?

F*CKING GREAT it worked :P sorry but i am sooo glad you cant imagine ^^

I changed this:

String userName = "CN=verena bit,OU=Lehrer,OU=ASR,dc=bodensee,dc=de";

into this:

String userName = "CN=verena bit,OU=Lehrer,OU=ASR";

SO WHY did it help to remove the BASE DN because ADLER_STEVEN is also using it and got no error msg ?

Could someone explain that to me?

[5650 byte] By [4tha] at [2007-11-27 9:44:39]
# 1

Because you are specifiying a base distinguished name in your ldap url, the ldap context will be rooted at that context and all subsequent objects will be relative to that base distinguished name.//connect to my domain controller

String ldapURL = "ldaps://rhein:636/dc=bodensee,dc=de";

andString userName = "CN=verena bit,OU=Lehrer,OU=ASR,DC=bodensee,DC=de";

results in an fully distinguished name of:CN=verena bit,OU=Lehrer,OU=ASR,DC=bodensee,DC=de,dc=bodensee,dc=de

Either specify your ldap url asString ldapURL = "ldaps://rhein:636";

and leave your username as is, or specify the user object relative to the base distinguished name in the ldapurlString userName = "CN=verena bit,OU=Lehrer,OU=ASR";

adler_stevena at 2007-7-12 23:51:48 > top of Java-index,Core,Core APIs...
# 2
String ldapURL = "ldaps://rhein:636/[b]dc=bodensee,dc=de[/b]";ok now i understand the last both "dc" statements made the both dc statements in the code obsolete or they caused an error. Thank you very much :)
4tha at 2007-7-12 23:51:48 > top of Java-index,Core,Core APIs...