을 시도 나는 쿼리가 있지만이 폴더 :(의 사용자를 얼마나 모르겠어요 귀하의 검색을 할 수있는 PrincipalSearcher
하고 "쿼리별로 예를 들어"주체를 사용하는 것은 : 당신이 이미하지 않은 경우
// create your domain context
string container = "OU=DBG,OU=THINCLIENT,OU=NPS,OU=services,DC=YourDomain,DC=com";
using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "YourDomain", container))
{
// define a "query-by-example" principal - here, we search for UserPrincipal
UserPrincipal qbeUser = new UserPrincipal(ctx);
// 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
의 새로운 기능. 또는 MSDN documentation on the System.DirectoryServices.AccountManagement 네임 스페이스를 참조하십시오.
당신은 당신의 참조에 System.DirectoryServices.AccountManagement
어셈블리에 대한 참조를 추가해야하며,이 같은 라인이 필요합니다 :이 작업을 수행하려면 코드 숨김 파일의 맨 위에
using System.DirectoryServices.AccountManagement;
을 .
UserPrincipal
에서 속성을 지정할 수 있으며 PrincipalSearcher
의 경우 "쿼리 별"로 사용할 수 있습니다.
작동하지 않습니다. – Tarasov