Solved

Is this possible ?

Posted on 2002-07-16
4
167 Views
Last Modified: 2013-11-24
Is this possible to access the Exchange server's Global address list using JNDI ?

0
Comment
Question by:cstsang
  • 2
  • 2
4 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 7158991
AFAIK, yes. You might be able to customise the following:

import javax.naming.*;
 import javax.naming.directory.*;
 import java.util.Hashtable;
 
 public class Search {
   public static void printSearchEnumeration(NamingEnumeration enum){
     try {
       while (enum.hasMore()) {
         SearchResult sr = (SearchResult)enum.next();
      System.out.println(">>>" + sr.getName());
      GetattrsAll.printAttrs(sr.getAttributes());
       }
      } catch (NamingException e) {
        e.printStackTrace();
      }
   }
   
   
   public static void main(String[] args) {
     // rechargement de l'environnement de l'initialisation du context
     Hashtable env = new Hashtable(11);
     env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
     env.put(Context.PROVIDER_URL, "ldap://digactive:389/dc=intraucad,dc=ucad,dc=sn");
     env.put(Context.SECURITY_AUTHENTICATION,"simple");
     env.put(Context.SECURITY_PRINCIPAL,"cn=administrateur,cn=users,dc=intraucad,dc=ucad,dc=sn");
     // specify the username
     env.put(Context.SECURITY_CREDENTIALS,"digactive");
     // specify the password
     try {
       // Crer le context initial
       DirContext ctx = new InitialDirContext(env);
       // Specifie les ids des attributs à retourner
       String[] attrIDs = {"sn", "telephonenumber", "mail"};
       // Specifie les attributs que doit avoir l'objet
       // cherché ici l'attribut ("sn")
       // avec la valeur "titi"
       // et un attribut "mail" .
       Attributes matchAttrs = new BasicAttributes(true);
       // ignore case
       matchAttrs.put(new BasicAttribute("sn", "titi"));
       matchAttrs.put(new BasicAttribute("mail"));
       // Cherche parmi les objets de "toto" ceux ayant de tels attribut
       NamingEnumeration answer = ctx.search( "ou=toto",matchAttrs, attrIDs);
       // Imprimer la reponse
       printSearchEnumeration(answer);
       // Clore le context ctx.close();
      } catch (Exception e) { e.printStackTrace();
    }
  }
}
0
 
LVL 7

Author Comment

by:cstsang
ID: 7159017
In fact, I need to get all the email address and user name from the global address list.
0
 
LVL 7

Author Comment

by:cstsang
ID: 7266137
I have tried your program, it doesn't work.
By the way, I haven't told you that I am using exchange 5.5 not 2000.That why your program cannot work.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 80 total points
ID: 7266595
The program's just a demo of using JNDI-LDAP. Since Exchange 5.5 supports LDAP, you should be able to adapt it to look at the global address book.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now