0

特定のグループのすべてのメール アドレスが必要です。私を助けてください

string filter1 = string.Format("(&(objectClass=group)(cn={0}))", "groupname");
        DirectorySearcher searcher = new DirectorySearcher(entry);
        searcher.Filter = filter1;
        searcher.SearchScope = SearchScope.Subtree;
        searcher.PropertiesToLoad.Add("member");
        SearchResult res = searcher.FindOne();
        ArrayList userNames = new ArrayList();
        if (res != null)
        {
            for (int counter = 0; counter <res.Properties["member"].Count; counter++)
            {
                string user = (string)res.Properties["member"][counter];
                userNames.Add(user);
            }
        }

ユーザー名とその他の詳細を取得していますが、メールが届きません。各ユーザーのメールアドレスを直接調べる方法を教えてください。

4

1 に答える 1

0

PrincipalContext このコードで試すことができます-クラスに基づいて

var username = "username";
var domain = "domain";
var emailAddresses = new List<string>();

var principalContext = new PrincipalContext(ContextType.Domain, domain);
var userPrincipal  = UserPrincipal.FindByIdentity(principalContext, username);
// Add the "mail" entry
emailAddresses.Add(userPrincipal.EmailAddress);

リンク: http: //msdn.microsoft.com/fr-fr/library/bb344891 (v = vs.90).aspx

于 2012-10-04T14:15:53.130 に答える