By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,837 Members | 1,842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,837 IT Pros & Developers. It's quick & easy.

Update openldap user from c#

P: 2
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.
Jul 24 '07 #1
Share this Question
Share on Google+
2 Replies


kenobewan
Expert 2.5K+
P: 4,871
Please copy & paste error message and give line number. Thanks.
Jul 24 '07 #2

P: 1
Try:

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.