How to search for users in Active Directory with C#
Last time I wrote about how you can reach the Active Directory search dialog in Windows 7. Today I’ll show you how to search comfortable for users in the Active Directory by using C#. The emphasis is on comfort, because there are quite a few articles on the subject in general, on the internet.
However, most of the shown methods/solutions are build exclusively around System.DirectoryServices.ActiveDirectory and the DirectorySearcher. But ever since .NET 3.5 it is also possible to search in the Active Directory much easier.
But let us come to the point. In the following example, I mostly use methods from the System.DirectoryServices.AccountManagement namespace. And here’s how:
//Create a shortcut to the appropriate Windows domain
PrincipalContext domainContext = new PrincipalContext(ContextType.Domain,
[…]
Basically, I have seen so far every new Windows version rather skeptical towards. And since I’ve been here from Windows 98 on, this were a good handful of Windows versions until now. Windows 7, however, has convinced me, and until a few days ago, I was sure not to miss out any of the older versions. As I said, until a few days ago.
I admit, the title of this article is somewhat misleading. The PHP function file_get_contents(), which can be used to read files from the internet into a string, just does not work with allow_url_fopen disabled. On that not even this article will change anything.
At the weekend I was looking for a way to find synonyms for a given word. After a quick search on the net I came across the Openthesaurus project, which offers an offline database of synonyms for download. However, I wanted to have a second source for comparison. After further searching, I went to the thesaurus of the “Wortschatz Leipzig” project. Although they offer no offline synonym database, but a free webservice.