我在Windows Vista Ultimate SP1上使用以下代码来查询我们的活动目录服务器以检查域上用户的用户名和密码.
public Object IsAuthenticated()
{
String domainAndUsername = strDomain + "\\" + strUser;
DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, strPass);
SearchResult result;
try
{
//Bind to the native AdsObject to force authentication.
DirectorySearcher search = new DirectorySearcher(entry) { Filter = ("(SAMAccountName=" + strUser + ")") };
search.PropertiesToLoad.Add("givenName"); // First Name
search.PropertiesToLoad.Add("sn"); // Last Name
search.PropertiesToLoad.Add("cn"); // Last Name
result = search.FindOne();
if (null == result)
{
return null;
}
//Update the new path to the user in …Run Code Online (Sandbox Code Playgroud) 我有一个前端,允许用户更改它的AD密码.
有没有办法获得特定用户的密码策略(例如细粒度)及其属性(长度,复杂性......)
有没有办法检查字符串"xyz121"对这个特定的政策?
编辑:我不想检查存储在活动目录中的当前密码.我想检查新密码是否可以安全进入活动目录.例如:用户在他的新密码"xyz121"中键入并想要更改它,但是活动目录只允许密码至少有8个字符.