I have the following code that loads a user's Active Directory DirectoryEntry object from the user's SID:
public static DirectoryEntry GetUserDirectoryEntry(SecurityIdentifier sid)
{
return new DirectoryEntry(string.Format("LDAP://<SID={0}>", sid.Value));
}
Is there a more efficient way to do this? I'm having to optimize my code because of performance issues, and I need to squeeze down to the absolute fastest code that I can. It doesn't necessarily have to load from an SID. I just need to know the most efficient way to get the users DirectoryEntry.
EDIT: I'm restricted to using .Net 2.0.