In this post, we will see how to resolve Passing the servername/Ldap inside “DirectoryEntry” Vs “PrincipalContext”
Question:I have this action method inside my ASP.NET MVC-5 .net 4.6:-
DirectoryEntryI need to pass the server/ldap as follow
("LDAP://mydomain.com:389/DC=mydomain,DC=com", ADusername, ADpassword)), while for the
PrincipalContextwe need to pass it as follow:-
(ContextType.Domain, "mydomain.com", ADusername, ADpassword)).. so i can not pass the ldap inside the
PrincipalContextnor the servrname only inside the
DirectoryEntry.. so is this the case? or i am doing things wrongly ? Thanks
Best Answer:You are correct.
UserPrincipal, etc.) was created to simplify things. However, it just uses the
DirectoryEntry, etc.) in the background. (except for
ValidateCredentials, which uses
I prefer to always use
DirectoryEntryand friends because it gives me more control over performance. That’s something I wrote an article about: Active Directory: Better performance
If you have better answer, please add a comment about this, thank you!