none
multiple domains in Active directory

    Question

  • hi all,

           I dont have much idea about Active Directory configuration, I just want to know some clarifications.

    1) can AD have more than one domains

    2) is Organization name for the AD is unique?(or AD can have more than one Organiation name)?

    3) I am using following code to create user mailbox, is it correct? and also how to get Organization name(currently I hard code the name, but i have to remove it as i am making an installer which will run on any client's exchange server machine)?

         DirectoryEntry container, user;
         CDOEXM.IMailboxStore mailbox;

         ActiveDs.ADSystemInfo ADInfo = new ActiveDs.ADSystemInfo();
         string DefaultNC ="DC=" + ADInfo.DomainDNSName.Substring(0, ADInfo.DomainDNSName.IndexOf(".")) + ",DC=" + ADInfo.DomainDNSName.Substring(ADInfo.DomainDNSName.IndexOf(".") + 1);
                container = new DirectoryEntry("LDAP://cn=users," + DefaultNC);
                user = container.Children.Add("cn=" + CommonName, "user");
                user.Properties["sAMAccountName"].Add(SAMAccountName);

                user.CommitChanges();
      
                mailbox = (IMailboxStore)user.NativeObject;
         string HomeMDB = "CN=Mailbox Store (" + System.Net.Dns.GetHostName() + "),CN=First Storage Group,"
                          + "CN=InformationStore,CN=" + System.Net.Dns.GetHostName() + ",CN=Servers,"
                          + "CN=First Administrative Group,CN=Administrative Groups,"
                          + "CN=" + OrgName + ",CN=Microsoft Exchange,CN=Services,"
                          + "CN=Configuration," + DefaultNC;
                mailbox.CreateMailbox(HomeMDB);

    Thanks in advance....

    Tuesday, April 20, 2010 1:41 PM

Answers

  • many many thanks Laeeq for your quick reply..

             yes I am just targeting the exch 2003 for now, but may be later on I will update it for exch 2007/2010.

    1. Yes AD can have more than one domain, which u can enumerate using .net's classes in System.DirectoryServices.ActiveDirectory namespace. : In that case new ActiveDs.ADSystemInfo().DomainDNSName returns which domain?  I am making an intaller so do I must have to take the domain name from user, so that I can create a mailbox.

    thanks again

    ActiveDs.ADSystemInfo().DomainDNSName will return the domain of the server where u r running your code. Domain of the server can also be seen in the FQDN of the server which is normally server.ADDomain.tld. This will only return one domain in all cases.

    Plz have a look into link to see how u can get multiple AD Domains using ActiveDS.IAds interface: VB6 Get List of Active Directory Domains or u can use the .net namespace which i mentioned in my last post.

    You can easily convert this code to C#.

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    • Marked as answer by pratikmehta9 Wednesday, April 21, 2010 12:28 PM
    Wednesday, April 21, 2010 12:19 PM

All replies

  • hi all,

           I dont have much idea about Active Directory configuration, I just want to know some clarifications.

    1) can AD have more than one domains

    2) is Organization name for the AD is unique?(or AD can have more than one Organiation name)?

    3) I am using following code to create user mailbox, is it correct? and also how to get Organization name(currently I hard code the name, but i have to remove it as i am making an installer which will run on any client's exchange server machine)?

         DirectoryEntry container, user;
         CDOEXM.IMailboxStore mailbox;

         ActiveDs.ADSystemInfo ADInfo = new ActiveDs.ADSystemInfo();
         string DefaultNC ="DC=" + ADInfo.DomainDNSName.Substring(0, ADInfo.DomainDNSName.IndexOf(".")) + ",DC=" + ADInfo.DomainDNSName.Substring(ADInfo.DomainDNSName.IndexOf(".") + 1);
                container = new DirectoryEntry("LDAP://cn=users," + DefaultNC);
                user = container.Children.Add("cn=" + CommonName, "user");
                user.Properties["sAMAccountName"].Add(SAMAccountName);

                user.CommitChanges();
      
                mailbox = (IMailboxStore)user.NativeObject;
         string HomeMDB = "CN=Mailbox Store (" + System.Net.Dns.GetHostName() + "),CN=First Storage Group,"
                          + "CN=InformationStore,CN=" + System.Net.Dns.GetHostName() + ",CN=Servers,"
                          + "CN=First Administrative Group,CN=Administrative Groups,"
                          + "CN=" + OrgName + ",CN=Microsoft Exchange,CN=Services,"
                          + "CN=Configuration," + DefaultNC;
                mailbox.CreateMailbox(HomeMDB);

    Thanks in advance....

    1. Yes AD can have more than one domain, which u can enumerate using .net's classes in System.DirectoryServices.ActiveDirectory namespace.

    2. In AD i think there could be more than one exchange organizations. You can enumerate exchange orgs using Directory Entry class from " AD path "CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=Domain,DC=com".

    You shoud not hard code the organization name.

    BTW are u just targetting exch 2003 or some later version?

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    Tuesday, April 20, 2010 7:09 PM
  • many many thanks Laeeq for your quick reply..

             yes I am just targeting the exch 2003 for now, but may be later on I will update it for exch 2007/2010.

    1. Yes AD can have more than one domain, which u can enumerate using .net's classes in System.DirectoryServices.ActiveDirectory namespace. : In that case new ActiveDs.ADSystemInfo().DomainDNSName returns which domain?  I am making an intaller so do I must have to take the domain name from user, so that I can create a mailbox.

    thanks again

    Wednesday, April 21, 2010 4:40 AM
  • many many thanks Laeeq for your quick reply..

             yes I am just targeting the exch 2003 for now, but may be later on I will update it for exch 2007/2010.

    1. Yes AD can have more than one domain, which u can enumerate using .net's classes in System.DirectoryServices.ActiveDirectory namespace. : In that case new ActiveDs.ADSystemInfo().DomainDNSName returns which domain?  I am making an intaller so do I must have to take the domain name from user, so that I can create a mailbox.

    thanks again

    ActiveDs.ADSystemInfo().DomainDNSName will return the domain of the server where u r running your code. Domain of the server can also be seen in the FQDN of the server which is normally server.ADDomain.tld. This will only return one domain in all cases.

    Plz have a look into link to see how u can get multiple AD Domains using ActiveDS.IAds interface: VB6 Get List of Active Directory Domains or u can use the .net namespace which i mentioned in my last post.

    You can easily convert this code to C#.

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    • Marked as answer by pratikmehta9 Wednesday, April 21, 2010 12:28 PM
    Wednesday, April 21, 2010 12:19 PM
  • thanks laeeq, your input is very useful for me..

     

    thanks again...

    • Marked as answer by pratikmehta9 Wednesday, April 21, 2010 12:28 PM
    • Unmarked as answer by pratikmehta9 Wednesday, April 21, 2010 12:28 PM
    Wednesday, April 21, 2010 12:28 PM