I'm having a problem writing a generic method to retrieve AD Groups or Users with a parameter that can be one of two types - either System.DirectoryServices.AccountManagement GroupPrincipal
or UserPrincipal
The method is as follows:-
private static IEnumerable<string> GetGroupsOrUsers<T>(T GroupOrUserPrincipal)
{
PrincipalSearcher ps = new PrincipalSearcher();
ps.QueryFilter = GroupOrUserPrincipal;
etc.........
}
The problem is the GroupOrUserPrincipal is showing the following error:-
Cannot implicitly convert type 'T' to System.DirectoryServices.AccountManagement.Principal
Am I able to do this or am I missing something ?