获取失败的Active Directory登录尝试数Active、Directory

2023-09-08 13:17:46 作者:梦带我旅行

下面是我如何让失败AD日志在我的旧的WebForms尝试次数登录应用程序:

Here is how I get the number of failed AD log in attempts in my old webforms log in app:

[Authentication.cs]

[Authentication.cs]

var pc = new PrincipalContext(ContextType.Domain, "blahnet.blahad.com", "dc=blahnet,dc=blahad,dc=org");
bool validated = pc.ValidateCredentials(username, password, ContextOptions.Negotiate);
var ADElement = IdentityType.SamAccountName;
var up = UserPrincipal.FindByIdentity(pc, ADElement, username);
int numberOfFailedLoginAttempts = up.BadLogonCount;

和这里是我迄今为止在我新的MVC 5登录应用程序的认证。

And here is what I have so far for authentication in my new MVC 5 login app.

[web.config文件]

[web.config]

    <membership defaultProvider="ADMembershipProvider">
      <providers>
        <clear />
        <add name="ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" attributeMapUsername="SamAccountName" />
      </providers>
    </membership>
  </system.web>
  <connectionStrings>
    <add name="ADConnectionString" connectionString="LDAP://blahnet.blahad.com:389/DC=blahnet,DC=blahad,DC=com" />
  </connectionStrings>

[AccountController.cs]

[AccountController.cs]

bool validated = Membership.ValidateUser(model.UserName, model.Password);

通过这种新方法,我怎么能得到失败AD日志的数量在试图像上面?

With this new method, how can I get the number of failed AD log in attempts like above?

任何帮助将是很大的AP preciated。

Any help would be greatly appreciated.

推荐答案

成员类是通用的。为了得到一个帐户的AD特定的属性,我的猜测是,你仍然要使用的帐户的 UserPrincipal 实例。顺便说一句,如果可能的话,你也可以使用的产品,如管理引擎的审核: HTTP:// WWW .manageengine.com /产品/主动目录审计/

Membership class is generic. To get that AD specific property of an account, my guess is you will still have to use UserPrincipal instance of the account. BTW, if possible you can also use a product like Manage Engine's Auditing: http://www.manageengine.com/products/active-directory-audit/

 
精彩推荐
图片推荐