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 2008
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:
- The domain name is returned
- 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.
|