troubleshooting Question

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

Avatar of one1082
one1082 asked on
DatabasesASPC#
8 Comments1 Solution9055 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
viperman1271

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros