Skip to main content
This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal

Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum


  

PreviousPrevious NextNext


~Lily Bubfanapuletsi 1.Sep.03 03:35 PM a Web browser
Applications Development 6.0.1 CF2 iSeries


I have an agent which at the moment queries an LDAP directory and prints the results in the Java Console/Domino server console.

It connects to the LDAP server using JNDI which is included in ND6. When run locally everything works OK but when run on the server I get the following errors:

09/01/2003 03:34:44 PM Agent error: Exception in setContext: javax.naming.CommunicationException: uk-bre-sed1.abc.com:389 [Root exception is java.lang.SecurityException: uk-bre-sed1.abc.com,-1]
09/01/2003 03:34:44 PM Agent error: java.lang.NullPointerException
09/01/2003 03:34:44 PM Agent error: at JavaAgent.NotesMain(JavaAgent.java:118)
09/01/2003 03:34:44 PM Agent error: at lotus.domino.AgentBase.runNotes(Unknown Source)
09/01/2003 03:34:44 PM Agent error: at lotus.domino.NotesThread.run(NotesThread.java:208)

The LDAP directory is visible to all and the Domino server can ping the LDAP server and vice versa.

Any idea what I'm doing wrong??

Thanks in advance,
Mark.

--- Code follows ---
import lotus.domino.*;
import javax.naming.*;
import javax.naming.directory.*;
import java.util.*;

public class JavaAgent extends AgentBase {

public static DirContext setContext(){
Hashtable DCvar = new Hashtable();
DCvar.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
DCvar.put(Context.PROVIDER_URL,"ldap://uk-bre-sed1.abc.com");
DCvar.put(Context.SECURITY_PRINCIPAL,"dc=abc,dc=com");
try{
//Create an initial Directory Context.
//This will create a connection to the Directory server
//with the attributes listed above.
//If the attributes are correct and the server is
//responding then a new Directory context will be created.
DirContext DirContext = new InitialDirContext(DCvar);
return DirContext;
} catch (javax.naming.NamingException ne){
//One of the attributes listed above is incorrect or
//the Directory server is not responding.
System.err.println ( "Exception in setContext: "+ne);
return null;
}
}
public static SearchControls setSearchControls(){
String [] attrReturned = new String [14];
attrReturned [0] = "givenName"; //First name
attrReturned [1] = "sn"; //Last name
attrReturned [2] = "secretary"; //Assistant
attrReturned [3] = "o"; //Company
attrReturned [4] = "DepartmentName"; //Department
attrReturned [5] = "employeeType"; //Employee Type
attrReturned [6] = "l"; //Location
attrReturned [7] = "manager"; //Line Manager
attrReturned [8] = "VPNmobile"; //Business Mobile
attrReturned [9] = "facsimilieTelephoneNumber"; //Fax
attrReturned [10] = "telephoneNumber"; //Office Phone
attrReturned [11] = "pager"; //Pager No
attrReturned [12] = "personalTitle"; //Title
attrReturned [13] = "preferredLanguage";//PreferredLanguage

//Create an empty SearchControls.
SearchControls searchCtls = new SearchControls();
//Populate the ReturningAttributes
searchCtls.setReturningAttributes(attrReturned);
//Set the scope of the search.
searchCtls.setSearchScope(searchCtls.SUBTREE_SCOPE);
return searchCtls;
}
public static String setSearchContext(){
//Set the Search base. This is the place where the search will start.
String searchAttr = new String("dc=abc,dc=com");
return searchAttr;
}
public static String setSearchString(String uid){
//Set the search string. The more exact of the search string
//the fewer number of entries that will be returned.
String searchString = new String ("uid="+uid);
return searchString;
}
public static void printEnumeration(NamingEnumeration ne1){
SearchResult searchResult;
Attributes attributes;
NamingEnumeration ne2;
try{
while (ne1.hasMore()){ //If there are more results to be
//then continue the loop.
searchResult = (SearchResult) ne1.next();
//Print the name of the object returned
System.out.println ("Attr: "+ searchResult.getName());
//Retrieve the attributes associated with the object
attributes = (Attributes)
searchResult.getAttributes();
//Cycle through all of the attributes
for(ne2 = attributes.getAll();ne2.hasMoreElements();){
//Get the next attribute from the entry
Attribute attr = (Attribute)ne2.next();
//Get the name of the attribute
String attrId = attr.getID();
//Cycle through all of the values associated with
//the current attribute.
for (Enumeration values = attr.getAll();
values.hasMoreElements();
//If you are retrieving attributes that are
//non text based then you will be unable
//to print them.
System.out.println(attrId+": "+ values.nextElement()));
}
//Print a line between the entries
System.out.println();
}
} catch (Exception e1){
//Oops got an error
System.out.println ("error: "+e1);
}
}
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();

// (Your code goes here)
DirContext DirContext;
SearchControls searchCtls;
String searchString;
String searchBase;
NamingEnumeration answer;

DirContext = setContext();
searchCtls = setSearchControls();
searchString = setSearchString("mzh0361");
searchBase = setSearchContext();
try{
answer = DirContext.search(searchBase,searchString,searchCtls);
printEnumeration(answer);
DirContext.close();
} catch (javax.naming.NamingException ne2){
System.out.println("Search error: " + ne2);
}
} catch(Exception e) {
e.printStackTrace();
}
}
}






Error connecting to LDAP server usi... (~Lily Bubfanapu... 1.Sep.03)
. . RE: Error connecting to LDAP server... (~Fred Asaveluch... 4.Sep.03)
. . RE: Error connecting to LDAP server... (~Judy Zekkrobur... 5.Sep.03)
. . RE: Error connecting to LDAP server... (~Lily Bubfanapu... 12.Sep.03)





  Document options
Print this pagePrint this page

 Search this forum

  Forum views and search
Date (threaded)
Date (flat)
With excerpt
Category
Platform
Release
Advanced search

 RSS feedsRSS
All forum posts RSS
All main topics RSS