I've LDAP credentials, those are
using this I can connect and get all users by using a software named "Softerra LDAP Administrator", but while using C#/ .net MVC I've used this code which gives "Unknown error (0x80005000)" while search.FindAll();. I have also tried without Port number.
DirectoryEntry myLdapConnection = new DirectoryEntry("LDAPS://ldap.abcd.net:636/", "uid=hris,ou=People,dc=testbd,dc=net", "abc123");
DirectorySearcher search = new DirectorySearcher(myLdapConnection) { Filter = ("(objectClass=*)") };
search.CacheResults = true;
SearchResultCollection allResults = search.FindAll(); //Getting "Unknown error (0x80005000)"
I've tried another way it also gives "Unknown error (0x80005000)"
DirectoryEntry nRoot = new DirectoryEntry("LDAPS://ldap.abcd.net:636/ou=People,dc=testbd,dc=net");
nRoot.AuthenticationType = AuthenticationTypes.None;
nRoot.Username = "uid=hris,ou=Group,dc=testbd,dc=net"; //full dn
nRoot.Password = "abc123";
DirectorySearcher nDS = new DirectorySearcher(nRoot);
nDS.SearchScope = SearchScope.Subtree;
nDS.Filter = "objectClass=*";
SearchResult sr = nDS.FindOne();// Getting ""Unknown error (0x80005000)"
I've tried many other ways but not getting proper data that software "Softerra LDAP Administrator" getting. Please help me through that I can all user information from LDAP and validate one user data. Thank you.
THE SOLUTION
var ldapDomainName= "LDAP://ldap.xserver.net";
var loginId = "testUser";
var password = "aa1111";
// assign user
var uid = "uid=" + loginId.Trim() + ",ou=People,dc=servicenginebd,dc=net";
// assign password
var passwordLdap = password;
// define LDAP connection
var root = new DirectoryEntry(
ldapDomainName, uid, passwordLdap,
AuthenticationTypes.None);
try
{
var connected = root.NativeObject;
return "LDAP Login SUCCESSFUL";
//isValid = true;
// no exception, login successful
}
catch (Exception ex)
{
// exception thrown, login failed
return "LDAP Login FAILED";
}
User contributions licensed under CC BY-SA 3.0