Questions tagged [principalsearcher]

21 questions
15
votes
2 answers

Does PrincipalSearchResult automatically dispose all elements in its collection?

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
Joe
  • 122,218
  • 32
  • 205
  • 338
6
votes
2 answers

Extend UserPrincipal class

I do the extension of the UserPrincipal class to retrieve some missing properties that i need: [DirectoryObjectClass("user")] [DirectoryRdnPrefix("CN")] class UserPrincipalExt : UserPrincipal { public UserPrincipalExt(PrincipalContext context) …
4
votes
1 answer

AD PrincipalSearcher: Search where property does not contain some value

Principal Searcher seems to do a great job when building a filter to find an object with a particular value. What about without? For example How do I build a filter to exclude everyone with "Joe" in their name. The code below would not work. …
Fred B
  • 175
  • 1
  • 3
  • 11
2
votes
1 answer

Query PrincipalSearcher for containing multiple strings

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 =…
Sam Stephenson
  • 5,200
  • 5
  • 27
  • 44
1
vote
0 answers

C# finding all Microsoft Accounts on machine

I am trying to get the UPN and Microsoft Accounts for all users on my machine using C#. I am currently logged into an Azure account, and whoami returns details as expected and that I am looking for (but for all users): PS C:\Windows\system32> whoami…
morleyc
  • 2,169
  • 10
  • 48
  • 108
1
vote
1 answer

ldap principalsearcher very slow

I want to get information from only 1 user out of 20,000 users. The response time of the method I used below is 40 seconds. What is the solution to this problem? public AuthenticatedUserProperties Info(string Username) { try …
Gökhan YILDIZ
  • 131
  • 3
  • 16
1
vote
1 answer

PrincipalContext: Exception Details: System.DirectoryServices.DirectoryServicesCOMException: An operations error occurred

I am trying to search AD for a user, but it keeps throwing an exception. The application is setup to use AppPool. and I am certain that the logged in user has access to search AD. Code: public static UserADInfoModel ResolveUserProperties(string…
1
vote
1 answer

Find if Active Directory is Enabled/Disabled with Email

I'm trying to find if a user has an Active Directory account by searching with their email address and checking the Enabled property (if I return Enabled as true - run code, if I return false - run other code, and if the results are null - return…
1
vote
1 answer

Complex Search Filtering with PrincipalSearcher

I am searching in Active Directory for specific SamAccountName values using the PrincipalSearcher object because I want to return UserPrincipal's. I was wondering how I can apply two filters to that search; one being the beginning of the account…
BlueBarren
  • 321
  • 7
  • 24
1
vote
1 answer

Get Count of members in a AD Group using PrincipalSearcher

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…
Richard
  • 27
  • 1
  • 6
1
vote
2 answers

How can i get all groups of a local user using ObjectQuery?

i try to display all groups a special User is in. I also know, that i could do it like this: public static List getUsers(){ PrincipalContext context = new PrincipalContext(ContextType.Machine, "computername"); …
1
vote
1 answer

How to include multiple OU from AD account in a single search using PrincipleSearcher in asp.net c#

Scenario: Active Directory username search should return results against a search item (i.e. Firstname or Surname). There are 6 countries that are setup as different organizational units for AD accounts. e.g. UK (OU= UK), France (OU = FR). Now user…
PineCone
  • 2,193
  • 12
  • 37
  • 78
1
vote
1 answer

Active Directory - weird behaviour

I'm trying to get informations (members of groups). I get every time the message "Information about the domain could not be retrieved (1355)" For getting the groups, it helped to try it just 2 times. The first time doesn't work, but the second time…
float
  • 1,265
  • 5
  • 22
  • 38
1
vote
2 answers

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

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…
0
votes
1 answer

Using PrincipalSearcher to find users matching pattern

I have a somewhat particular situation I couldn't find answers to through google. I need to query my active directory for users whose SAMAccountName fits a particular pattern (3 letters followed by 4 digits). Currently I pull the entire list of…
1
2