如何从AD读取字段badPwdCount和LockoutThreshold [英] How to read fields badPwdCount and LockoutThreshold From AD

查看:325
本文介绍了如何从AD读取字段badPwdCount和LockoutThreshold的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以编程方式读取Windows帐户的AD字段badPwdCount和LockoutThreshold?

How can I programmatically read the AD fields badPwdCount and LockoutThreshold of an windows account?

谢谢,

PG

推荐答案

尝试使用默认AD路径和凭据获取用户"john"的"badPwdCount"的最简单代码:

using( var de = new DirectoryEntry() )
{
	using( var ds = new DirectorySearcher( de ) )
	{
		ds.Filter = "(&(objectClass=user)(sAMAccountName=john))";
		var r = ds.FindOne();
		Console.WriteLine( r.Properties["badPwdCount"][0] );
	}
}




还添加对System.DirectoryServices的引用。


这篇关于如何从AD读取字段badPwdCount和LockoutThreshold的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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