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.Server Bind;
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.M essage = The directory property cannot be found in the cache.
Thank you in advance for your help!
Tim
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.Server
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",
de.CommitChanges();
}
.
.
.
The error occurs at this line:
user.Invoke("setPassword",
and returns these exceptions:
Exception.Message = Exception has been thrown by the target of an invocation.
Exception.InnerException.M
Thank you in advance for your help!
Tim
I don't think it's case sensitive, but you could try:
user.Invoke("SetPassword", new object[] { newPassword });
^
user.Invoke("SetPassword",
^
ASKER
Yeah I've tried both ways, that's not the issue.
ASKER
Still looking for some help guys!!!!
FYI: I can get and set other items using stuff like:
user.InvokeSet("EmailAddre ss", new object[] { "email@email.com" });
FYI: I can get and set other items using stuff like:
user.InvokeSet("EmailAddre
So, have you tried to set the password via InvokeSet("SetPassword", ...)... treating it as a property, rather than a method?
ASKER
Returns a "Member not found" inner exception.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Forced accept.
Computer101
EE Admin
Computer101
EE Admin
ASKER
Would this affect how the "SetPassword" function runs? I've also tried the "ChangePassword" function and get the same error.