0

I am having issues connecting to a public LDAP using PrincipalContext. I can get directory entry working fine:

string sDomain = "LDAP://ldap.itd.umich.edu:389";
string sDefaultOU = "ou=System Groups,ou=Groups,dc=umich,dc=edu";
string sServiceUser = "cn=Directory Manager,o=University of Michigan,c=us";
string sServicePassword = "";

DirectoryEntry de = new DirectoryEntry(sDomain + "/" + sDefaultOU, sServiceUser, sServicePassword, AuthenticationTypes.ServerBind);
DirectorySearcher ds = new DirectorySearcher(de);
SearchResult sr = ds.FindOne();

But when I try to do the same thing with PrincipalContext I get a null reference error:

sDomain = "ldap.itd.umich.edu";
PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, sDomain, sDefaultOU, sServiceUser, "");

Any ideas what I am doing wrong?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Does this link help? http://stackoverflow.com/questions/2538064/active-directory-services-principalcontext-what-is-the-dn-of-a-container-o – abhi Jan 07 '14 at 20:54
  • No, but thanks! I am not trying to authenticate using AD credentials. Technically i should only have to do this: PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, sDomain); – Patrick Wensel Jan 07 '14 at 21:11
  • The new `PrincipalContext` only works against **Active Directory**, and my guess is this public LDAP server is not actually using AD. – marc_s Jan 07 '14 at 21:22

0 Answers0