471,604 Members | 1,359 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,604 software developers and data experts.

Update openldap user from c#

Hi all,

I want to update openldap directory from c#. I used following code for make Directory entry as below.

public static DirectoryEntry GetDirectoryEntry()
DirectoryEntry de = new DirectoryEntry();
de.Path = "LDAP://,DC=example,DC=com";
de.AuthenticationType = AuthenticationTypes.ServerBind;

return de;

I thought it is working properly. But my user update mathod does not work properly.It is as below,

public void ModifyUser(string userDisplayName, string username, string password)
DirectoryEntry de = GetDirectoryEntry();
de.Username = username;
de.Password = password;

DirectorySearcher ds = new DirectorySearcher(de);
ds.Filter = ("((objectclass=user)(uid=" + username+ "))");

ds.SearchScope = SearchScope.Subtree;

SearchResult results = ds.FindOne();

if (results != null)
DirectoryEntry updateEntry = results.GetDirectoryEntry();
updateEntry.Properties["password"].Value =password;
catch (Exception ex)
txt1.Text = ex.ToString();


It gives error as an invalid dn syntax.

Please anyone know about this please help me as soon as possible.

Jul 24 '07 #1
2 5436
4,871 Expert 4TB
Please copy & paste error message and give line number. Thanks.
Jul 24 '07 #2

de.Path = "LDAP://DC=YOURDOMAIN,DC=com";

Where YOURDOMAIN is your domain name
Sep 4 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by stegger | last post: by
1 post views Thread by jdelimon | last post: by
reply views Thread by mmatthe | last post: by
3 posts views Thread by dorrit.Riemenschneider | last post: by
1 post views Thread by Gert Albertse | last post: by
reply views Thread by David | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.