Solved

Is this possible ?

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.

708 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

18 Experts available now in Live!

Get 1:1 Help Now