Link to home
Start Free TrialLog in
Avatar of one1082
one1082

asked on

DirectoryEntry.Invoke("SetPassword", .... The directory property cannot be found in the cache

Hello,
  I'm having trouble changing a user's password in LDAP using ASP .Net 2.0 / C#.

The LDAP server is: OpenLDAP on Red Hat 4EL.


The code is as follows:

de = new DirectoryEntry(ldapPath, ldapUsername, ldapPassword);
de.AuthenticationType = AuthenticationTypes.ServerBind;

DirectorySearcher srch = new DirectorySearcher(de);
srch.Filter = "(CN=user.name)";

SearchResult result = srch.FindOne();

if (result != null)
{
     // User found, try to reset their password
     try
     {
          DirectoryEntry user = result.GetDirectoryEntry();
          user.Invoke("setPassword", new object[] { newPassword });
          de.CommitChanges();
     }
.
.
.

The error occurs at this line:
          user.Invoke("setPassword", new object[] { newPassword });

and returns these exceptions:
          Exception.Message = Exception has been thrown by the target of an invocation.
          Exception.InnerException.Message = The directory property cannot be found in the cache.

Thank you in advance for your help!

Tim
Avatar of one1082
one1082

ASKER

Here's a quick info update / addition... within the LDAP, the user's password attribute is actually named "userPassword"

Would this affect how the "SetPassword" function runs?  I've also tried the "ChangePassword" function and get the same error.
I don't think it's case sensitive, but you could try:

user.Invoke("SetPassword", new object[] { newPassword });
                     ^
Avatar of one1082

ASKER

Yeah I've tried both ways, that's not the issue.
Avatar of one1082

ASKER

Still looking for some help guys!!!!

FYI:  I can get and set other items using stuff like:

user.InvokeSet("EmailAddress", new object[] { "email@email.com" });
So, have you tried to set the password via InvokeSet("SetPassword", ...)... treating it as a property, rather than a method?
Avatar of one1082

ASKER

Returns a "Member not found" inner exception.
ASKER CERTIFIED SOLUTION
Avatar of viperman1271
viperman1271
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forced accept.

Computer101
EE Admin