Solved

Is this possible ?

Posted on 2002-07-16
4
172 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 117
java 8 lambda expresssions exception handling 3 92
Arrays.asList  VS  ArrayList 4 62
reverse digits of a number using for loop 5 46
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

831 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