Questions tagged [directorysearcher]

Use this tag for question related to the DirectorySearcher .Net Framework class.

DirectorySearcher is a .Net Framework class for performing queries against Active Directory Domain Services.

112 questions
18
votes
3 answers

How can I search users in Active Directory based on surname and first name?

I'm trying to search for users in AD with their surname (sn) and first name (givenName) using DirectorySearcher in .NET. I can find a user based on sAMAccountname with this code: DirectorySearcher searcher1 = new DirectorySearcher(entry); …
bAN
  • 13,375
  • 16
  • 60
  • 93
9
votes
2 answers

list all local users using directory services

The following method I created seem does not work. An error always happens on foreach loop. NotSupportedException was unhandled...The provider does not support searching and cannot search WinNT://WIN7,computer. I'm querying the local machine …
ikel
  • 1,790
  • 6
  • 31
  • 61
8
votes
3 answers

How can I find what Organizational Units a computer is part of? ( Active Directory C# )

I want to find the most specific OU my computer belongs to in C#. I have code that will get the information I need, but it doesn't feel robust and it would require complicated parsing. Are there better alternatives? Thoughts? Any help is…
user1507986
  • 83
  • 1
  • 1
  • 4
4
votes
2 answers

Why is my directory search taking so long?

I've been troubleshooting performance in a REST API I've built that, among other things, returns a list of users from Active Directory based on a search term that is provided. Based on some logging that I've built in for test purposes, I can see…
3
votes
2 answers

DirectorySearcher Asynchronous using await

I'm using .net 4.7.2 (not core) and C#. I need to come up with a way to to not block my current async tasks and I have a need to search for a user as part of these tasks. I've done DirectorySearcher operations previously so I know the attachment to…
Zonus
  • 2,313
  • 2
  • 26
  • 48
3
votes
0 answers

Intermittent referral errors with DirectorySearcher

I am using DirectorySearcher to look up user accounts based on email addresses: using (var searcher = new DirectorySearcher { SearchRoot = new DirectoryEntry($"LDAP://DC={companyOfficeLocation},DC={companyDomain},DC=com"), SearchScope =…
ChaseMedallion
  • 20,860
  • 17
  • 88
  • 152
3
votes
1 answer

Specify Active Directory Domain Controller via DirectoryEntry or DirectorySearcher?

I can specify the domain controller when I want to search through AD using this: $principalContext = New-Object 'System.DirectoryServices.AccountManagement.PrincipalContext'([System.DirectoryServices.AccountManagement.ContextType]::Domain,…
3
votes
1 answer

DirectorySearcher works for mail, but not for cn C#

I'm french so please be indulgent with my poor english :P I have a problem when i want to retrieve a user by CN against LDAPS. This code works fine when i want to retrieve users by mail, but not by cn ... Don't understand why. When i run my research…
gjdass
  • 146
  • 7
3
votes
2 answers

Querying LDAP in VB.NET. I have the user account, and I want a list of groups the user in in

I know the SAMAccountName, and now want to populate a list of groups with entries that reflect this user's group membership across the whole directory. Here's my start, but I'm stumped: Dim path As String =…
2
votes
1 answer

Quickest way to do a [adsisearcher] and store in a hashtable or dictionary collection list

I am using [adsisearcher] to grab AD User info because it's way faster than get-aduser. I am also trying to figure out how to add it into a hashtable or dictionary using LINQ or perhaps any other alternative that is fast. For me I'm trying to get…
Koobah84
  • 185
  • 2
  • 12
2
votes
1 answer

Performance issue with a SearchResultCollection from an LDAP request

I've encountered a bit of a performance issue in a little Active Directory searching tool i've created. The issue is extremely similar to this one, essentially i'm retrieving a list of users from AD via the below code: DirectoryEntry dEntry = new…
Erik
  • 91
  • 12
2
votes
2 answers

LDAP Connecting with IP address and Port Number

The company I work for has a product that uses Active Directory to enable our product's security features using a library that includes DirectoryEntry and DirectorySearcher components. If someone is a member of group FOO, they have standard access.…
user153923
2
votes
1 answer

Active Directory: The server could not be contacted using DirectorySearcher

I keep getting the error The server could not be contacted. When i'm trying to run my code: I've searched for a few hours, and i'm still unable contact the server. DirectorySearcher directorySearcher = new DirectorySearcher(); string path =…
2
votes
0 answers

How to resolve LDAP bind errors “The server is not operational” and “The directory service is unavailable”

We've an application that uses LDAP for authentication. The application is deployed on four MiddleWare servers in a load balanced configuration using F5. Though there are 8 domain controllers in the AD store, we continue to get an error on all MW…
2
votes
1 answer

Read / Process large number of data using DirectorySearcher API

Context Active Directory instance with 200k Users in an OU Potential to grow upto 1 M in our domain Not an expert in this ground. I am trying to come up with a solution design for a scenario where I need to poll AD and Check PwdLastSet and…
MSI
  • 1,124
  • 8
  • 23
1
2 3 4 5 6 7 8