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://192.248.8.239/OU=People,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)
{
try
{
DirectoryEntry updateEntry = results.GetDirectoryEntry();
updateEntry.Properties["password"].Value =password;
updateEntry.CommitChanges();
updateEntry.Close();
}
catch (Exception ex)
{
txt1.Text = ex.ToString();
}
}
de.Close();
}
It gives error as an invalid dn syntax.
Please anyone know about this please help me as soon as possible.
Thanks,
Jagath.