在工作中的 AD 中,我们有一些启用邮件的安全组。我正在使用 System.DirectoryServices.AccountManagement 命名空间,如下所示:
List<GroupPrincipal> result = new List<GroupPrincipal>();
using (PrincipalContext domain = new PrincipalContext(ContextType.Domain, userinfo[0]))
using (UserPrincipal user = UserPrincipal.FindByIdentity(domain, username))
{
if (user != null)
{
PrincipalSearchResult<Principal> groups = user.GetAuthorizationGroups();
int totalGroupCounter = 0;
StringBuilder output = new StringBuilder();
List<GroupPrincipal> securityGroups = new List<GroupPrincipal>();
List<GroupPrincipal> distributionGroups = new List<GroupPrincipal>();
foreach (Principal group in groups)
{
totalGroupCounter++;
if (((GroupPrincipal)group).IsSecurityGroup.Value)
securityGroups.Add((GroupPrincipal)group);
else
distributionGroups.Add((GroupPrincipal)group);
}
}
}
有了这些信息,找到群组电子邮件地址的正确方法是什么?