Trouble Connecting MS Exchange

hi,

i got the following error message when i try to connect to an ms exchange server.

javax.naming.NamingException: [LDAP: error code 1 - 00000000: LdapErr: DSID-0C090627, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, vece; remaining name '(OU=TESTUSER)'

The same paramters used in an vb program worked.

any idea what the problem could be?

I create the context as follows

Hashtable env =new Hashtable();

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

env.put(Context.PROVIDER_URL,"LDAP://192.168.100.23:389");

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

env.put(Context.SECURITY_PRINCIPAL,"cn=Administrator");

env.put(Context.SECURITY_CREDENTIALS,"");

LdapContext ctx =new InitialLdapContext(env,null);

SearchControls ctls =new SearchControls();

ctls.setReturningObjFlag(true);

ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);

String[] ret_attr =new String[]{"displayName","mail"};

ctls.setReturningAttributes(ret_attr);

// Specify the search filter to match any object

// Search for objects using filter

NamingEnumeration ret = ctx.search("(OU=TESTUSER)","", ctls);

[1845 byte] By [SaschaJanza] at [2007-11-27 10:43:52]
# 1

ok. after a littel try and error i got it work.

Hashtable env = new Hashtable();

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

env.put(Context.PROVIDER_URL, "LDAP://192.168.100.23:389");

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

env.put(Context.SECURITY_PRINCIPAL,"Administrator");

env.put(Context.SECURITY_CREDENTIALS,"Password");

env.put(Context.REFERRAL, "follow");

LdapContext ctx = new InitialLdapContext(env,null);

SearchControls ctls = new SearchControls();

ctls.setReturningObjFlag(true);

ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);

String[] ret_attr = new String[] {"displayName","mail"};

ctls.setReturningAttributes(ret_attr);

// Specify the search filter to match any object

// Search for objects using filter

NamingEnumeration ret = ctx.search("OU=TESTUSER,DC=2CEXCHANGE,DC=LOCAL","objectClass=*", ctls);

SaschaJanza at 2007-7-28 20:03:16 > top of Java-index,Core,Core APIs...