. NET 3.5에 도입 된 System.DirectoryServices.AccountManagement
네임 스페이스를 사용하면 훨씬 쉽게 될 수 있습니다. AD LDS가 명시 적으로 지원됩니다 - Managing Directory Security Principals in the .NET Framework 3.5
먼저 당신의 작업에 대한 컨텍스트를 설정해야합니다 :
// create a context for an AD LDS store pointing to the
// partition root using the credentials for a user in the AD LDS store
// and SSL for encryption
PrincipalContext ldsContext = new PrincipalContext(
ContextType.ApplicationDirectory, "sea-dc-02.fabrikam.com:50001",
"ou=ADAM Users,o=microsoft,c=us",
ContextOptions.SecureSocketLayer | ContextOptions.SimpleBind,
"CN=administrator,OU=ADAM Users,O=Microsoft,C=US ", "[email protected]");
을 다음 당신은 PrincipalSearcher
을 만들고 정의하는 것
여기에 대한 모든 읽기 "검색어 별 예제"스타일로 찾으십시오.
// create a principal object representation to describe
// what will be searched
UserPrincipal user = new UserPrincipal(ldsContext);
// define the properties of the search (this can use wildcards)
user.Enabled = false;
user.Name = "user*";
// create a principal searcher for running a search operation
PrincipalSearcher pS = new PrincipalSearcher();
// assign the query filter property for the principal object you created
// you can also pass the user principal in the PrincipalSearcher constructor
pS.QueryFilter = user;
// run the query
PrincipalSearchResult<Principal> results = pS.FindAll();
Console.WriteLine("Disabled accounts starting with a name of 'user':");
foreach (Principal result in results)
{
Console.WriteLine("name: {0}", result.Name);
}
꽤 멋진, 어? 새로운 S.DS.AM
네임 스페이스를 사용할 수 있다면!
cool. 나는 아직 LDAP 토지에 머물러 있었다. 이전 검색어와 동일한 계정 제한으로 인해 어려움을 겪고 있다면 손을 안다는 사실을 알고 있습니까? 1000 또는 1500입니다. – hal9000
@Hal Diggs : [MSDN docs for PrincipalSearcher] (http://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.principalsearcher.aspx) - 기본 페이지 크기는 256KB의 데이터이지만 다른 것으로 설정 될 수 있습니다. –
내 대답에 대답, 예 ** PrincipleSearcher는 1000 한계가 **하지만 UserPrincipal을 매개 변수로 사용하여 PrincipleSearcher를 구성하면 해결할 수 있습니다 ** PrincipleSearcher (UserPrincipal) **, 1000+ 결과. 이상하게도 MSDN에 대한이 주석은 본 적이 없습니다. – hal9000