Solved

Is this possible ?

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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…
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…

837 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