Created
April 13, 2016 11:23
-
-
Save gunnarmagholder/ef2e2dd5204ec8c2830514edfc5fac96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IEnumerable<UserAccount> GetPage(string sortField, int start, int Number) | |
{ | |
UserPrincipalEx findAllUsers = new UserPrincipalEx(thisOU); | |
PrincipalSearcher ps = new PrincipalSearcher(findAllUsers); | |
((DirectorySearcher) ps.GetUnderlyingSearcher()).PageSize = 0; | |
((DirectorySearcher)ps.GetUnderlyingSearcher()).Sort = new SortOption("cn", SortDirection.Ascending); | |
((DirectorySearcher)ps.GetUnderlyingSearcher()).VirtualListView = new DirectoryVirtualListView(0, Number, start); | |
PrincipalSearchResult<Principal> result = ps.FindAll(); | |
foreach (UserPrincipalEx user in result) | |
{ | |
string firstName = user.GivenName; | |
string lastName = user.Surname; | |
string orgKennzeichen = user.ExtensionAttribute8; | |
string samAccountName = user.SamAccountName; | |
UserAccount _user = new UserAccount() | |
{ | |
FirstName = firstName, | |
LastName = lastName, | |
OrgKennzeichen = orgKennzeichen, | |
SAMAccountName = samAccountName | |
}; | |
yield return _user; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment