.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


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


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


Where LdapConnection is an instance of LdapManager

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


Post Condition

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