LDAP Records Password Change Automatic in C#

时间:2016-04-25 09:36:29

标签: ldap

I'm new in Ldap now I tried changed ldap records' password with c#. for example; users in ldap username:12345678900 password:78900 I can do bellow with help

try
    {
        searchRoot = new DirectoryEntry(String.Format("LDAP://{0}/{1}", 
            domainController, container), 
            adminUser, adminPassword, authenticationTypes);

        searcher = new DirectorySearcher(searchRoot);
        searcher.Filter = String.Format("sAMAccountName={0}", userName);
        searcher.SearchScope = SearchScope.Subtree;
        searcher.CacheResults = false;

        SearchResult searchResult = searcher.FindOne(); 

catch (Exception ex)
    {
        return ex.ToString();
    }

how to do I?

1 个答案:

答案 0 :(得分:0)

我不熟悉C#LDAP API,但它看起来与JNDI类似,SearchResult为您提供Context或DN,您可以从中获得Context通过查找,然后您可以通过Context更改属性。