2011-08-12 8 views

答えて

1

を働いていなかった、アクティブディレクトリ内のすべてのアクティブユーザーをフェッチするためのフィルタを作成したいですSystem.DirectoryServices.AccountManagement(S.DS.AM)名前空間。

あなたの検索を行うことPrincipalSearcherと「例による問合せ」プリンシパルを使用することができます。

// create your domain context 
PrincipalContext ctx = new PrincipalContext(ContextType.Domain); 

// define a "query-by-example" principal - here, we search for a UserPrincipal 
// which is not enabled (not active) 
UserPrincipal qbeUser = new UserPrincipal(ctx); 
qbeUser.Enabled = false; 

// create your principal searcher passing in the QBE principal  
PrincipalSearcher srch = new PrincipalSearcher(qbeUser); 

// find all matches 
foreach(var found in srch.FindAll()) 
{ 
    // do whatever here - "found" is of type "Principal" - it could be user, group, computer.....   
} 

あなたがまだの場合は - 絶対に作る方法をうまく示しMSDNの記事Managing Directory Security Principals in the .NET Framework 3.5を読みますSystem.DirectoryServices.AccountManagement

+0

おかげで、私は(条件のフィルタを追加する方法を知りたいと思った|(sAMAccountNameを= { 0})(mailnickname = {0}))samaccountnameのプロパティは設定できますが、mailnicknameは設定できません。私のリストには、特定のエイリアスとしてmailnicknameを持つユーザーがいます。 – nipiv

0

www.joeware.netからadfindを取得し、フィルタをテストするために使用することができます - adfind -f "<your filter here>" - デフォルトはこのトリックを行います。私はそれだけで、このようなユーザーに適用範囲をさらにでしょうが、あなたが貼り付けられた何

が正確になります。あなたの応答のための

(&(objectClass=user)(objectCategory=person)(|(samaccountname={0})(mailnickname={0}))(!(userAccountControl:1.2.840.113556.1.4.803:=2))) 
関連する問題