> Thanx for ur reply.
> I am able to get list of users from Domino LDAP ,
> but now i want 2 get the list of users in Active
> directory.
> Can u suggest wht changes i have to make in my
> earlier code ?
Changes to what earlier code? I see no code.
Or should you not just be using a sys user credentials?
Ted.
I am using th following code for getting the list of users ->
public class LDAP {
private String tCtx="com.sun.jndi.ldap.LdapCtxFactory";
//private String tAuth="simple";
private String tAuth="simple";
private String org="C=IN";
private String tURL="ldap://server01:389";
private Properties env = null;
public static final int AUTH_SUCCESS= 1;
/** A constant representing that authentication failed. */
public static final int AUTH_FAILURE= 2;
/** A constant representing that user ID is invalid. */
public static final int AUTH_INVALIDUSER= 3;
/** A constant representing that error is not one of authentication failure or invalid user. */
public static final int AUTH_OTHER= 4;
// constructor
private String fullName;
private String commonName;
private String abbrevatedName;
public LDAP() {
try{
ResourceBundle rbDomino = ResourceBundle.getBundle("Domino", Locale.getDefault());
Enumeration enumDomino = rbDomino.getKeys();
while(enumDomino.hasMoreElements()){
String strKey = (String)enumDomino.nextElement();
if(strKey != null && strKey.equals("ip-address")){
tURL = rbDomino.getString(strKey);
}
else if(strKey != null && strKey.equals("org")){
org = rbDomino.getString(strKey);
}
}
}catch(MissingResourceException e){
System.out.println("Property file not defined.");
}
env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, tCtx);
env.put(Context.PROVIDER_URL, tURL);
env.put(Context.SECURITY_AUTHENTICATION, tAuth);
}
public ArrayList getAllUsers(){
String userName = null;System.out.println(" Getting allUsers ");
NamingEnumeration userInfo = null;
SearchResult sr = null;
String filter = null;
SearchControls ctls = new SearchControls();
ArrayList grouplist = new ArrayList();
grouplist.add("");
filter = "uid=*";
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
try {
DirContext authenticationctx = new InitialDirContext(env);
userInfo = authenticationctx.search(org, filter, ctls);
while(userInfo.hasMoreElements()){
sr = (SearchResult) userInfo.next();
userName = sr.getName();
if(userName.indexOf("//C") > 0)
userName = userName.substring(userName.indexOf("//C")+2);
userName = userName.substring(userName.indexOf("/C")+1);
grouplist.add(userName);
}
return grouplist;
}catch (NoSuchElementException nse) {
System.err.println("no matching user found.");
return null;
}catch (NamingException ne) {
System.err.println("naming exception"+ne);
return null;
}catch(Exception e){
e.printStackTrace();
return null;
}
}
}
What changes i need to do in this code , so that it works with AD ?