DirectoryEntry is a .Net class that encapsulates a node or object in the Active Directory Domain Services hierarchy.
Questions tagged [directoryentry]
209 questions
15
votes
3 answers
how to iterate over non-English file names in PHP
I have a directory which contains several files, many of which has non-english name. I am using PHP in Windows 7.
I want to list the filename and their content using PHP.
Currently I am using DirectoryIterator and file_get_contents. This works for…

Sabya
- 11,534
- 17
- 67
- 94
14
votes
1 answer
LdapConnection Vs DirectoryEntry
Can anybody explain the difference between using LdapConnection/SearchRequest and DirectoryEntry/DirectorySearcher for Searching users in ActiveDirectory.
Which one is best suited for interacting with AD?

Biju Thomas
- 1,079
- 3
- 14
- 27
13
votes
6 answers
How to provide DirectoryEntry.Exists with credentials?
This morning I discovered a nice method (DirectoryEntry.Exists), that should be able to check whether an Active Directory object exists on the server. So I tried with a simple:
if (DirectoryEntry.Exists(path)) {}
Of course it lacks any overloads to…

Herman Cordes
- 4,628
- 9
- 51
- 87
9
votes
4 answers
Given a user's SID, how can I get the AD DirectoryEntry?
I have the user's SID as byte[] within windowsPrincipal.getIdentity().getSid().
How can I get an Active Directory entry (DirectoryEntry) from the SID?

mtm
- 125
- 2
- 2
- 6
9
votes
4 answers
Best way to quickly determine whether a user account is a member of an AD group?
I currently have some code that pulls down a list of users in a group and then iterates through that group to determine if a given account exists, but it seems like there ought to be a more concise (and perhaps faster) way to accomplish this.
This…

JohnFx
- 34,542
- 18
- 104
- 162
9
votes
2 answers
Change AD user Terminal Server properties with C#
I am using System.DirectoryServices.DirectoryEntry to create AD user and everything work fine except for some Remote Desktop specifics properties.
Exemple :
newUser.Properties["msTSConnectClientDrives"].Value =…

Karnalta
- 518
- 1
- 9
- 24
9
votes
4 answers
How do I query LDAP from C# to resolve Oracle TNS hostname while using managed ODP.NET?
Further to my previous Question, which I managed to answer myself with help from the Oracle forums, I now have another issue which follows on from the earlier one (provided for background).
I wish to query LDAP directly from my C# code to perform an…

Neo
- 4,145
- 6
- 53
- 76
9
votes
4 answers
How to know if my DirectoryEntry is really connected to my LDAP directory?
I'm connecting to a LDAP directory in C#, so I've used the DirectoryEntry class.
When you do the "new DirectoryEntry" with address, login, and password it is supposed to connect to the LDAP directory.
However, even if the connection didn't work, it…

Ksempac
- 1,842
- 2
- 18
- 23
8
votes
1 answer
How I can find a User with the GUID(objectGUID) Parameter in Active Directory
In my ASP.NET Application I get Informations from Active Directory. I must get Informations about a User with the GUID Informations (example: a28a6a34dsfdsf57d9e54f945a241) but I don't know how I can use the filter right for this search :/
for…

Tarasov
- 3,625
- 19
- 68
- 128
8
votes
2 answers
How to change System.DirectoryEntry "uSNChanged" attribute value to an Int64
I'm trying to get the Int64 value of a Directory Services object's "uSNChanged" value. Unfortunately, it is always coming back as a COM object of some kind. I've tried using casting to Int64, calling Int64.Parse(), and calling Convert.ToInt64().…

Simon Gillbee
- 3,932
- 4
- 35
- 48
7
votes
3 answers
Impersonation and DirectoryEntry
I am impersonating a user account successfully, but I am not able to use the impersonated account to bind to AD and pull down a DirectoryEntry.
The below code outputs:
Before impersonation I am: DOMAIN\user
After impersonation I am:…

Elijah W. Gagne
- 2,801
- 4
- 31
- 29
5
votes
2 answers
How to set AccountExpires in VB.NET via a AD DirectoryEntry
I needed to set the accountExpires property in the AD DirectoryEntry couldn't find a simple answer.
Found some…

Nick Giles
- 562
- 1
- 6
- 15
5
votes
1 answer
Force local user to change password at next login with C#
I'm writing a function for a web app in ASP.NET where the client logs into the server machine, which is Windows authenticated against the local users on the server. The function I am writing resets the users password and emails them the new one. I…

jnevelson
- 2,092
- 2
- 21
- 31
5
votes
2 answers
How to get a list of all domains?
I'm trying to get all domains that are available in the Windows Login dialog (in the Domain dropdown).
I've tried the following code but it only returns the domain I am logged into. Am I missing something?
StringCollection domainList = new…

AngryHacker
- 59,598
- 102
- 325
- 594
5
votes
3 answers
Set Windows/AD password so that it "never expires"?
Here is my code:
using (DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer"))
{
DirectoryEntry NewUser = AD.Children.Add(username, "user");
string password = username + "123";
…

Leslie
- 105
- 1
- 2
- 4