No attribute value being returned?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, May 28, 2002 03:57 AM

I am having trouble getting the value of the attribute I am looking for. I can't seem to execute the while loop at all. Any suggestions what might be wrong? public class ReturnInfo { public static String info=""; public static String supervisor=""; public static String GetParameters(String CourseID) { try { // Hashtable for environmental information Hashtable env = new Hashtable(); System.out.println("Create initial context..."); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://localhost/dc=may,dc=ie"); env.put(Context.S   More>>
			
I am having trouble getting the value of the attribute I am looking for.
I can't seem to execute the while loop at all.
Any suggestions what might be wrong?

public class ReturnInfo {

public static String info="";
public static String supervisor="";

public static String GetParameters(String CourseID)
{
try { // Hashtable for environmental information
Hashtable env = new Hashtable();
System.out.println("Create initial context...");

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost/dc=may,dc=ie");
env.put(Context.SECURITY_PRINCIPAL, "cn=Keith,dc=may,dc=ie");
env.put(Context.SECURITY_CREDENTIALS, "optilab");

// Get a reference to a directory context
DirContext ctx = new InitialDirContext(env);
System.out.println("Context : "+ctx.getNameInNamespace());

if(CourseID.equalsIgnoreCase("csse"))
{
String MY_ATTRS[]={"CSSEsupervisor"};
SearchControls constraints = new SearchControls();
NamingEnumeration results = ctx.search("","ou=Academic",constraints);
if (results == null){ System.out.println("Results equals null value");}
while (results != null && results.hasMore())
{
SearchResult sr = (SearchResult) results.next();
Attributes ar = ctx.getAttributes("ou=Academic",MY_ATTRS);

Attribute attr=ar.get(MY_ATTRS[0]); System.out.println("Got attribute 0");
for(Enumeration vals=attr.getAll();vals.hasMoreElements();)
{
supervisor= String.valueOf(vals.nextElement());
System.out.println("supervisor: "+supervisor) ;
}//END FOR LOOP

info+=(supervisor);

System.out.println("info: "+info) ;

}// END WHILE LOOP
}// end if

ctx.close();
} //END TRY
catch (Exception e) { e.printStackTrace(); System.exit(1); }
return (info);

} //END GetParameters()
}//END ReturnInfo


Thanks for your help!!!
   <<Less
About | Sitemap | Contact