Hi
I am using the following LDAP query to retrieve data from the Active Directory environment:
< LDAP://kworld.myserver.com:123/dc=uk,dc=kworld,dc=myserver,dc=com>;(&(ObjectCategory=person)(ObjectClass=user)(employeeID=*)(!(userAccountControl=514)));UserPrincipalName,CreateTimeStamp,GivenName,TelephoneNumber,HomePhone,Name,sn,Company,c,l,st,StreetAddress,distinguishedname;subtree
I am getting the error -
LDAP: error code 1 - 00000000: LdapErr: DSID-0C090627- Get Active Directory RootDSE with JNDI
//-----------------------------------------------------------------------------------------//
// My Java code for the above is :
//-----------------------------------------------------------------------------------------//
import javax.naming.*;
import javax.naming.directory.*;
import java.util.*;
public class KPMGADSearch{
public static void main(String args[]) throws Exception{
dc.controlArrtibutesInResults();
}
/**
* This methos shows how to search and control arrtibutes returned in the result.
* Create search controls and allow java objects to be returned in the results.
*/
public void controlArrtibutesInResults() throws Exception{
DirContext ctx= getDirContext();
// Specify the ids of the attributes to return
String[] attrIDs = {"CreateTimeStamp" , "ModifyTimeStamp" , "GivenName" , "TelephoneNumber" , "HomePhone" , "Name" , "sn" , "Company" , "Title" ,"Mobile" , "c" , "l" , "st" , "Mail" , "EmployeeID" , "PostalCode" , "distinguishedname"};
SearchControls ctls = new SearchControls();
ctls.setReturningAttributes (attrIDs);
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
String filter = "(&(ObjectCategory=person)(ObjectClass=user)(employeeID=*)(!(userAccountControl=514)))";
String base = "dc=uk,dc=kworld,dc=kpmg,dc=com";
NamingEnumeration answer = ctx.search(base, filter, ctls);
formatResults(answer);
ctx.close();
}
/*
* Generic method to format the NamingEnumeration returned from a search.
*/
public void formatResults(NamingEnumeration enumeration) throws Exception{
int count=0;
try {
while (enumeration.hasMore ()) {
SearchResult sr = (SearchResult)enumeration.next();
System.out.println("SEARCH RESULT:" + sr.getName());
formatAttributes(sr.getAttributes());
System.out.println("====================================================");
count++;
}
System.out.println("Search returned "+ count+ " results");
} catch (NamingException e) {
e.printStackTrace();
}
}
/*
* Generic method to format the Attributes .Displays all the multiple values of
* each Attribute in the Attributes
*/
public void formatAttributes(Attributes attrs) throws Exception{
if (attrs == null) {
System.out.println("This result has no attributes");
} else {
try {
for (NamingEnumeration enumeration = attrs.getAll(); enumeration.hasMore() {
Attribute attrib = (Attribute)enumeration.next();
System.out.println("ATTRIBUTE :" + attrib.getID());
for (NamingEnumeration e = attrib.getAll();e.hasMore()
System.out.println("\t\t = " + e.next());
}
} catch (NamingException e) {
e.printStackTrace();
}
}
}
/** Generic method to obtain a reference to a DirContext */
public DirContext getDirContext() throws Exception{
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory ");
env.put(Context.PROVIDER_URL, "LDAP://kworld.myserver.com:123");
// Create the initial context
DirContext ctx = new InitialDirContext(env);
return ctx;
}
}
//-----------------------------------------------------------------------------------------//
I am getting the following error :
javax.naming.NamingException: [LDAP: error code 1 - 00000000: LdapErr: DSID-0C090627, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, vece remaining name 'dc=uk,dc=kworld,dc=myserver,dc=com'
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3028)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2934)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2740)
at com.sun.jndi.ldap.LdapCtx.searchAux (LdapCtx.java:1811)
at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1734)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search (PartialCompositeDirContext.java:328)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:313)
at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:238)
at com.hp.kpmg.ldap.KPMGADSearch.controlArrtibutesInResults(KPMGADSearch.java:118)
at com.hp.kpmg.ldap.KPMGADSearch.main(KPMGADSearch.java:44)
Exception in thread "main"
Can i get some help on this ,
No clue .
thanks in advance,
Sumon
I am using the following LDAP query to retrieve data from the Active Directory environment:
< LDAP://kworld.myserver.com:123/dc=uk,dc=kworld,dc=myserver,dc=com>;(&(ObjectCategory=person)(ObjectClass=user)(employeeID=*)(!(userAccountControl=514)));UserPrincipalName,CreateTimeStamp,GivenName,TelephoneNumber,HomePhone,Name,sn,Company,c,l,st,StreetAddress,distinguishedname;subtree
I am getting the error -
LDAP: error code 1 - 00000000: LdapErr: DSID-0C090627- Get Active Directory RootDSE with JNDI
//-----------------------------------------------------------------------------------------//
// My Java code for the above is :
//-----------------------------------------------------------------------------------------//
import javax.naming.*;
import javax.naming.directory.*;
import java.util.*;
public class KPMGADSearch{
public static void main(String args[]) throws Exception{
dc.controlArrtibutesInResults();
}
/**
* This methos shows how to search and control arrtibutes returned in the result.
* Create search controls and allow java objects to be returned in the results.
*/
public void controlArrtibutesInResults() throws Exception{
DirContext ctx= getDirContext();
// Specify the ids of the attributes to return
String[] attrIDs = {"CreateTimeStamp" , "ModifyTimeStamp" , "GivenName" , "TelephoneNumber" , "HomePhone" , "Name" , "sn" , "Company" , "Title" ,"Mobile" , "c" , "l" , "st" , "Mail" , "EmployeeID" , "PostalCode" , "distinguishedname"};
SearchControls ctls = new SearchControls();
ctls.setReturningAttributes (attrIDs);
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
String filter = "(&(ObjectCategory=person)(ObjectClass=user)(employeeID=*)(!(userAccountControl=514)))";
String base = "dc=uk,dc=kworld,dc=kpmg,dc=com";
NamingEnumeration answer = ctx.search(base, filter, ctls);
formatResults(answer);
ctx.close();
}
/*
* Generic method to format the NamingEnumeration returned from a search.
*/
public void formatResults(NamingEnumeration enumeration) throws Exception{
int count=0;
try {
while (enumeration.hasMore ()) {
SearchResult sr = (SearchResult)enumeration.next();
System.out.println("SEARCH RESULT:" + sr.getName());
formatAttributes(sr.getAttributes());
System.out.println("====================================================");
count++;
}
System.out.println("Search returned "+ count+ " results");
} catch (NamingException e) {
e.printStackTrace();
}
}
/*
* Generic method to format the Attributes .Displays all the multiple values of
* each Attribute in the Attributes
*/
public void formatAttributes(Attributes attrs) throws Exception{
if (attrs == null) {
System.out.println("This result has no attributes");
} else {
try {
for (NamingEnumeration enumeration = attrs.getAll(); enumeration.hasMore() {
Attribute attrib = (Attribute)enumeration.next();
System.out.println("ATTRIBUTE :" + attrib.getID());
for (NamingEnumeration e = attrib.getAll();e.hasMore()
System.out.println("\t\t = " + e.next());
}
} catch (NamingException e) {
e.printStackTrace();
}
}
}
/** Generic method to obtain a reference to a DirContext */
public DirContext getDirContext() throws Exception{
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory ");
env.put(Context.PROVIDER_URL, "LDAP://kworld.myserver.com:123");
// Create the initial context
DirContext ctx = new InitialDirContext(env);
return ctx;
}
}
//-----------------------------------------------------------------------------------------//
I am getting the following error :
javax.naming.NamingException: [LDAP: error code 1 - 00000000: LdapErr: DSID-0C090627, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, vece remaining name 'dc=uk,dc=kworld,dc=myserver,dc=com'
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3028)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2934)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2740)
at com.sun.jndi.ldap.LdapCtx.searchAux (LdapCtx.java:1811)
at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1734)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search (PartialCompositeDirContext.java:328)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:313)
at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:238)
at com.hp.kpmg.ldap.KPMGADSearch.controlArrtibutesInResults(KPMGADSearch.java:118)
at com.hp.kpmg.ldap.KPMGADSearch.main(KPMGADSearch.java:44)
Exception in thread "main"
Can i get some help on this ,
No clue .
thanks in advance,
Sumon