How to read the value of external attributes(all attributes) from ldap in c#
How to acess ldap active directory external attributes
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
How to read the value of external attributes(all attributes) from ldap in c#
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vishal YelveRank #178 · 13.6K reputationPosted Dec 10, 2022, 2:20 AM EST
https://www.codemag.com/article/1312041/Using-Active-Directory-in-.NET
https://support.zpesystems.com/portal/en/kb/articles/how-to-configure-active-directory-or-ldap-authentication-provider
https://decovar.dev/blog/2022/06/16/dotnet-ldap-authentication/
Pankajkumar PatelRank #181 · 13.4K reputationPosted Dec 13, 2022, 12:02 AM EST
Hi Kavya M,
To read the value of external attributes(all attributes) from ldap in c#:
string currentUserSid = WindowsIdentity.GetCurrent().User.Value; PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "helpdesk.wat.edu"); UserPrincipal up = UserPrincipal.FindByIdentity(ctx, IdentityType.Sid, currentUserSid); DirectoryEntry entry = up.GetUnderlyingObject() as DirectoryEntry; PropertyCollection props = entry.Properties; foreach (string propName in props.PropertyNames) { if (entry.Properties[propName].Value != null) { Console.WriteLine(propName + " = " + entry.Properties[propName].Value.ToString()); } else { Console.WriteLine(propName + " = NULL"); } } Console.ReadKey();For more details:
Hope this will help you!