为什么使用相同的C#代码在不同计算机上的AD中更改密码会产生不同的速度? [英] why does using the same c# code to change password in AD in different computer make different speed?

查看:68
本文介绍了为什么使用相同的C#代码在不同计算机上的AD中更改密码会产生不同的速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用System.DirectoryServices中的类来更改AD中的密码.像这样的代码:

I used the class in System.DirectoryServices to change password in AD. The code like this:

DirectoryEntry _directoryEntry = new DirectoryEntry(ldapPath, user, pwd, AuthenticationTypes.Secure);
    public bool ChangePassword(string userPath, string newPassword)
    {
        try
        {
            if (userPath != null && _directoryEntry != null)
            {
                _directoryEntry.Path = userPath;
                //Set the password
                _directoryEntry.Invoke("SetPassword", new object[] { newPassword });
                _directoryEntry.CommitChanges();
                return true;
            }
        }
        catch (Exception ex)
        {
            //Invalid Login or the domain controller is not contactable
            throw ex;
        }
        finally
        {
            _directoryEntry.Close();
            _directoryEntry = null;
        }
        return false;
    }



我在其他计算机上执行了这些代码.时间从几毫秒到几秒钟.

为什么在不同的环境中执行相同的代码来更改AD中的密码会花费不同的时间?我花了很多时间来解决这个问题,但仍然没有结果.有人可以告诉我吗?非常感谢您!!!!!



I executed these codes on different computer. The time spent from several ms to several seconds.

why does the same code executed in different Environment to change password in AD spent different time? I have spent a lot of time in dealing this problem but still no result. Can anybody tell me? Thank you very much!!!!!

推荐答案

[

这篇关于为什么使用相同的C#代码在不同计算机上的AD中更改密码会产生不同的速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆