exchangefreaks.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how to retrieve multiple values of same type using getAttrib

 
Post new topic   Reply to topic    exchangefreaks.com Forum Index -> MS Exchange Applications
Author Message
shivaraj



Joined: 05 Aug 2007
Posts: 23

PostPosted: Fri Feb 02, 2007 9:45 am    Post subject: how to retrieve multiple values of same type using getAttrib Reply with quote

Hi,
I am trying to get homeMDBBL fileds from Mailbox Store. I was able to
traverse till CN=Mailbox Store

( CN=Mailbox Store (REVA),CN=First Storage
Group,CN=InformationStore,CN=REVA,CN=Servers,CN=First Administrative
Group,CN=Administrative Groups,CN=First Organization,CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=exchdomain,DC=com )

but after this when i tried to get homeMDBBL for this mailbox store
using ctx.getAttributes function, its returing only the first
homeMDBBL value. But how can i retrieve all homeMDBBL values using
getAttributes fucntion? I am not getting how to make it in loop or to
iterate for all homeMDBBL fileds. Is there any other API available to
get it done? If so please let me know. For those who want to have a
look at code or those who want to start with LDAP here with I have
attached the code.

/
******************************************************************************/

import javax.naming.*;
import javax.naming.directory.*;

import java.util.Hashtable;
import java.io.*;
import java.util.*;
import java.lang.*;

class adcheck {


public static Enumeration getObjectsOfType(DirContext ctx, String dn,
String type) throws Exception
{

String filter = "objectClass=" + type;
return (ctx.search(dn, filter, null));
}


private static String stripOutName(String str)
{
return (str.substring(str.indexOf('=') + 1).trim());
}

public static void main(String args[])
{
try {
DirContext ctx = null;
Hashtable dnsEnv = new Hashtable();
Properties env = new Properties();

String exchBaseDN = "CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=exchdomain,DC=com";
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://
16.180.204.123:389");
env.put(Context.SECURITY_PRINCIPAL,
"CN=Administrator,CN=Users,DC=exchdomain,DC=com");
env.put(Context.SECURITY_CREDENTIALS, "gone2far*");


/* String exchBaseDN = "CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=selabdev,DC=com";
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://15.70.185.250:389");
env.put(Context.SECURITY_PRINCIPAL,
"CN=Administrator,CN=Users,DC=selabdev,DC=com");
env.put(Context.SECURITY_CREDENTIALS, "gone2far#");
*/

ctx = new InitialDirContext(env);

Enumeration enumeration = getObjectsOfType(ctx,
exchBaseDN, "msExchOrganizationContainer");

while (enumeration.hasMoreElements())
{
System.out.println("getting admin groups...");
NameClassPair adminConNCP = (NameClassPair)
enumeration.nextElement();
String orgConDN = adminConNCP.getName() + "," +
exchBaseDN;

Enumeration adminEnum = getObjectsOfType(ctx,
orgConDN, "msExchAdminGroupContainer");

//System.out.println("adminConNCP is = "+adminConNCP);
System.out.println("\norganization : "+orgConDN);
//System.out.println("adminEnum is = "+adminEnum);
while (adminEnum.hasMoreElements())
{
//get Servers
NameClassPair groupConNCP = (NameClassPair)
adminEnum.nextElement();
String groupConDN = groupConNCP.getName() + "," +
orgConDN;
Enumeration groupEnum = getObjectsOfType(ctx,
groupConDN, "msExchAdminGroup");
System.out.println("\n\t groups info : "+groupConDN);
while (groupEnum.hasMoreElements())
{

//get Server
NameClassPair groupNCP = (NameClassPair)
groupEnum.nextElement();
String groupDN = groupNCP.getName() + "," +
groupConDN;
System.out.println("\n\t\t groupDN : "+groupDN);
Enumeration serverConEnum = getObjectsOfType(ctx,
groupDN, "msExchServersContainer");
while (serverConEnum.hasMoreElements())
{
NameClassPair serverConNCP = (NameClassPair)
serverConEnum.nextElement();
String serverConDN = serverConNCP.getName() +
"," + groupDN;
Enumeration serverEnum =
getObjectsOfType(ctx, serverConDN, "msExchExchangeServer");
System.out.println("\n\t\t\t Servers :
"+serverConDN);
while (serverEnum.hasMoreElements())
{

Hashtable apps = new Hashtable();
NameClassPair serverNCP = (NameClassPair)
serverEnum.nextElement();

String serverDN = serverNCP.getName() + ","
+ serverConDN;
System.out.println("\n\t\t\t\tserverDN is =
"+serverDN);
Enumeration infoStoreEnum =
getObjectsOfType(ctx, serverDN, "msExchInformationStore");
while (infoStoreEnum.hasMoreElements())
{
Hashtable groups = new Hashtable();
NameClassPair infoStoreNCP =
(NameClassPair) infoStoreEnum.nextElement();
String infoStoreDN =
infoStoreNCP.getName() + "," + serverDN;
System.out.println("\n\t\t\t\t
\tinformationStore : "+infoStoreDN);
Enumeration storageGroupEnum =
getObjectsOfType(ctx, infoStoreDN, "msExchStorageGroup");
while (storageGroupEnum.hasMoreElements())
{
Hashtable stores = new
Hashtable();
NameClassPair storageGroupNCP =
(NameClassPair) storageGroupEnum.nextElement();
String storageGroupDN =
storageGroupNCP.getName() + "," + infoStoreDN;
System.out.println("\n\t\t\t\t\t
\tstorageGroup : "+storageGroupDN);
Enumeration storeEnum =
getObjectsOfType(ctx, storageGroupDN, "msExchPrivateMDB");
while (storeEnum.hasMoreElements())
{
NameClassPair storeNCP =
(NameClassPair) storeEnum.nextElement();
String storeDN =
storeNCP.getName() + "," + storageGroupDN;
System.out.println("\n\t\t\t\t
\t\t\tstore : "+storeDN);

/******************/


String array[] =
{"homeMDBBL","msExchEDBFile", "msExchEDBOffline", "objectClass"};
Attributes attrs =
ctx.getAttributes(storeDN);
NamingEnumeration ae =
attrs.getAll();
while (ae.hasMoreElements())
{
System.out.println("\n inside while");
Attribute attr = (Attribute) ae.next();
if (attr.getID().equals("homeMDBBL"))
{
String name = (String) attr.get();
System.out.println("\n\t\t\t\t\t\t\t\tname is =
"+name);
// getuserDetails(name);
}
}


/*****************/

}
}
}
}
}
}
}
}
}catch(Exception e){
System.out.println("EXCEPTION e ="+e);
}


}//main
}

/*******************************************/

please help in resolving this.

Regards,
Shivaraj

Archived from group: microsoft>public>exchange>applications
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    exchangefreaks.com Forum Index -> MS Exchange Applications All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group