views:

562

answers:

3

Our user store is an LDAP server called eDirectory. How do you change user passwords using System.DirectoryServices.Protocols?

A: 

You need to remove the password and then re-add it. When I did this I used the LDAP library from Novell. You may have to play around with DirectoryEntry to get it to work.

Deleting non readable attribute from eDirectory - LDAP through ADSI/System.DirectoryServices


you might run into issues depending on the type of password you are using in eDirectory

LDAP / Universal Password with eDirectory 8.8


How to change eDirectory or Universal Password through LDAP here is an ldif sample

dn: cn=<myuser>,ou=<myou>,o=<myo>
changetype: modify
replace: userPassword
userPassword: <newPassWord>
Matthew Whited
The c# library from Novell doesn't support SSL. So, I can't really use it. I think I have to use S.DS.P
Ronnie Overby
I don't currently have an LDAP server running (let alone eDirectory) so I can't provide much more help. But I hope this at least gets you in the ball park.
Matthew Whited
A: 

I've used code similar to this to connect to a Sun One-based LDAP to change a user's password. (Shouldn't be that different from Novell eDirectory...)

using System.DirectoryServices.Protocols;
using System.Net;

//...

// Connect to the directory:
LdapDirectoryIdentifier ldi = new LdapDirectoryIdentifier("theServerOrDirectoryName");
// You might need to specify a full DN for "theUsername" (I had to):
NetworkCredential nc = new NetworkCredential("theUsername", "theOldPassword");
// You might need to experiment with setting a different AuthType:
LdapConnection connection = new LdapConnection(ldi, nc, AuthType.Negotiate);

DirectoryAttributeModification modifyUserPassword = new DirectoryAttributeModification();
modifyUserPassword.Operation = DirectoryAttributeOperation.Replace;
modifyUserPassword.Name = "userPassword";
modifyUserPassword.Add("theNewPassword");

ModifyRequest modifyRequest = new ModifyRequest("theUsername", modifyUserPassword);
DirectoryResponse response = connection.SendRequest(modifyRequest);
Per Noalt
A: 

I never could get this to work. I just accepted the best sounding answer.

Ronnie Overby