How to access Microsoft Exchange?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, February 26, 2002 07:01 PM

I am trying to read a person's email address from Microsoft Exchange Server. The code below is based on the "Getattr" example in the JNDI Tutorial. The ctx.getAttributes() method always throws a NameNotFoundException: [LDAP Error Code 32 - No Such Object]. class Getattr { public static void main(String[] args) { // Identify service provider to use Hashtable env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://13.13.13.13"); try { // Create the initial directory context DirContext ctx = new InitialDirContext(env);    More>>

I am trying to read a person's email address from Microsoft Exchange Server. The code below is based on the "Getattr" example in the JNDI Tutorial.


The ctx.getAttributes() method always throws a NameNotFoundException: [LDAP Error Code 32 - No Such Object].


			

class Getattr {
public static void main(String[] args) {
// Identify service provider to use
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://13.13.13.13");

try {
// Create the initial directory context
DirContext ctx = new InitialDirContext(env);

// Ask for all attributes of the object
Attributes attrs = ctx.getAttributes("cn=training1,ou=people");

// Find the email and print it
System.out.println("email: " + attrs.get("mail").get());

// Close the context when we're done
ctx.close();
} catch (NamingException e) {
System.err.println("Problem getting attribute: " + e);
}
}

   <<Less

Re: How to access Microsoft Exchange?

Posted By:   Nicholas_Whitehead  
Posted On:   Wednesday, February 27, 2002 09:06 AM

Wing-Keet;

It looks like you might be missing the Organization. It might be something like o=leong.com. With this in mind, you have two different places where you can implement it:




  • env.put(Context.PROVIDER_URL, "ldap://13.13.13.13/o=leong.com");



  • Attributes attrs = ctx.getAttributes("cn=training1,ou=people,o=leong.com");





Hope this helps.

About | Sitemap | Contact