File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Blatant Advertising and the fly likes Connectionto Acitve directory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Other » Blatant Advertising
Bookmark "Connectionto Acitve directory" Watch "Connectionto Acitve directory" New topic
Author

Connectionto Acitve directory

Rachana R
Greenhorn

Joined: Oct 31, 2008
Posts: 3
Hello All,

I am using the following class for connection to AD.

public class ADTestConnection {

public static void main(String[] args) {

Hashtable environment = new Hashtable();
String myPassword = "set00wave";

environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
// environment.put(Context.PROVIDER_URL, "ldap://" + myActiveDirectoryServer + ":389");//389

environment.put(Context.SECURITY_AUTHENTICATION, "simple");
// environment.put(Context.SECURITY_PRINCIPAL, "CN=" + myUser + ",CN=Users,DC=" + myDomain + ",DC=COM");


environment.put(Context.SECURITY_CREDENTIALS, "mypassword");
try
{
DirContext context = new InitialDirContext(environment);
System.out.println("Connection Successful!!");
}
catch (NamingException e)
{
e.printStackTrace();
}


}
}



After exectuion I am getting the following error -

javax.naming.ServiceUnavailableException: [url] socket closed
at com.sun.jndi.ldap.Connection.readReply(Connection.java:410)
at com.sun.jndi.ldap.LdapClient.ldapBind(LdapClient.java:340)
at com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:193)
at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2640)
at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:290)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:136)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:66)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:195)
at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:80)
at com.geam.ADTestConnection.main(ADTestConnection.java:56)
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3742
    
  16
It's probably because you're not telling it which server to connect to.


Joanne
 
Don't get me started about those stupid light bulbs.
 
subject: Connectionto Acitve directory