码迷,mamicode.com
首页 > 其他好文 > 详细

修改域中用户密码

时间:2014-06-07 15:20:59      阅读:275      评论:0      收藏:0      [点我收藏+]

标签:c   class   blog   code   a   com   

static void Main(string[] args)
        {
            //string path = @"LDAP://CN=sp\administrator";
            string username = "administrator";
            string password = "6yhn^YHN";
            string newPwd = "7ujm&UJM";
            //DirectoryEntry de = new DirectoryEntry(path, username, password);
            //de.Invoke("ChangePassword", new object[] { password, newPwd });
            //de.CommitChanges();
            
            ChangeWinUserPasswd(username,password ,newPwd);
        }
        public static void ChangeWinUserPasswd(string username, string oldPwd, string newPwd)
        {
            DirectoryEntry localMachine = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
            DirectoryEntry user = localMachine.Children.Find(username, "user");
            object[] password = new object[] { oldPwd, newPwd };
            object ret = user.Invoke("ChangePassword", password);
            user.CommitChanges();
            localMachine.Close();
            user.Close();
        }

修改域中用户密码,布布扣,bubuko.com

修改域中用户密码

标签:c   class   blog   code   a   com   

原文地址:http://blog.csdn.net/u014316433/article/details/28394129

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!