principalsearcher

Does PrincipalSearchResult<T> automatically dispose all elements in its collection?

笑着哭i 提交于 2019-12-17 23:34:41
问题 Can't find anything in the MSDN documentation on this. I.e. is it enough to do, say: using(PrincipalSearcher searcher = ...) { foreach (var principal in searcher.FindAll()) { ... do something ... } // The PrincipalSearchResult<T> returned by searcher.FindAll is disposed here } which is what most examples I've seen do, or should I do: using(PrincipalSearcher searcher = ...) { foreach(var principal in searcher.FindAll()) { using (principal) { // ... do something ... } } } The latter (explicitly

Get Count of members in a AD Group using PrincipalSearcher

£可爱£侵袭症+ 提交于 2019-12-13 02:27:53
问题 Env : Visual Studio 2013, FrameWork 4.5, Telerik Controls, C#, WebForm application Using : System.DirectoryServices and System.DirectoryServices.AccountManagement I'm making a search tools so a user can search for a active directory group name in multiple forest/domain. The search return a list of 1 or more group and I put that list in a RadGrid (Telerik). Each row of the grid is a AD Group. I would like to display an additional information that show the user how many(count?) members(users)

Query PrincipalSearcher for containing multiple strings

佐手、 提交于 2019-12-10 23:52:35
问题 I want to be able to query the active directory give a list of all groups containing certain words like Users or Administrators below is what i've got so far PrincipalContext ctx = new PrincipalContext(ContextType.Domain); GroupPrincipal qbeGroup = new GroupPrincipal(ctx); qbeGroup.DisplayName = "Administrators"; qbeGroup.DisplayName = "Users"; PrincipalSearcher srch = new PrincipalSearcher(qbeGroup); return srch.FindAll().Select(g => g.Name).ToArray(); This code doesn't even seem to filter

Search Users in Active Directory based on First Name, Last Name and Display Name

瘦欲@ 提交于 2019-12-04 18:44:28
I trying to search my organization Active directory for users. If the FirstName or LastName or DisplayName matches a particular string value, it should return the users. My Code: // create your domain context PrincipalContext ctx = new PrincipalContext(ContextType.Domain); UserPrincipal qbeUser = new UserPrincipal(ctx); qbeUser.GivenName = "Ramesh*"; // qbeUser.Surname = "Ramesh*"; // qbeUser.DisplayName= "Ramesh*"; PrincipalSearcher srch = new PrincipalSearcher(qbeUser); // find all matches foreach(var found in srch.FindAll()) { // } The problem is that I am able to search by only one filter.