Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

active directory

Status
Not open for further replies.

hyrogen

Programmer
Jul 10, 2003
60
0
0
GB
Hi,

Im wanting to write a jsp/java script that finds who is currently logged in through active directory.

Im totally new to this so dont really know where to start. Has any body got any ideas? or just a simple script to get me started. Also, will I require to make any changes on our server so that Java can connect to the AD?

Many thanks! :)
 
Thanks for the links, I've had some partial success with the following code:

Hashtable env= new Hashtable(11);
env.put(Context.SECURITY_AUTHENTICATION,"simple");
env.put(Context.SECURITY_PRINCIPAL,"name@mydomain");//User
env.put(Context.SECURITY_CREDENTIALS, "mypass");//Password
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL,"ldap://mydomain:389/DC=mydomain");
try {
DirContext ctx = new InitialDirContext(env);
String[] sAttrIDs = new String[2];
Attributes attr = ctx.getAttributes("");
System.out.println("Domain Name:"+ attr.get("name").get());
}
catch(NamingException e) {
System.err.println("Problem getting attribute: " + e);
}

However Im getting an error with the Attributes attr = ctx.getAttributes("");

Problem getting attribute: javax.naming.PartialResultException: [LDAP: error code 10 - 0000202B: RefErr: DSID-031006E0, data 0, 1 access points
ref 1: 'mydomain'

Any ideas?

 
Thanks, I managed to figure it out. All I had to do was remove the /DC=mydomain out of the Provider_URL line. Ive now managed to retrieve attributes and values, but I do not now how to find out if the client machine is logged into active directory?

Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top