Checking if an Active Directory Group Exists using C# or VB .Net
With this function you can check if an Active Directory Group exists or not. Simply returns a boolean.
Method: GroupExists
Parameters: (string) Group
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
and logged in.
Functionality
The method is called passing the Group as a string. Three
things can then occur:
- If the Group exists and the method returns true.
- If the Group does not exist the
method returns false
- An Exception will be thrown for other errors
Example
Where LdapConnection is an instance of LdapManager
public Boolean groupExists(String group)
{
try
{
return LdapConnection.GroupExists(group);
}
catch (Exception)
{
throw;
}
}
Post Condition
There is no residual state the connection remains connected to the ADDS
server
|