.NET Active Directory Wrapper    
Access Active Directory From Your C# or VB .Net Code
 

Getting the Domain Name of your Active Directory using C# or VB .Net

This is a simple method to return the doamin name of the ADDS server

Method: GetDomainName

Parameters:  (string) Server name

Programming Languages Supported

ASP.NET, C#, VB.Net, Visual Studio 2010, Visual Sutdio 2012

Precondition

An instance of the LDAP manager must be instantiated for a valid ADDS server.

Functionality

The method is called passing the Username as a string. Three things can then occur:

  1. The domain name is returned
  2. An Exception will be thrown for other errors

Example

Where LdapConnection is an instance of LdapManager

        public String GetDomainName(String server)
        {
            try
            {
                return LdapConnection.GetDomainName(server);
                
            }
            catch (Exception)
            {

                throw;
            }
        }

Post Condition

This method does not result in any "Login" context.