0

在我的网络应用程序中,我有一个login.aspx页面。当我输入用户名和密码时,我需要在远程服务器上验证它。他们只向我提供服务器名称(路径)和域名(不知道密码和用户名)。怎么做到呢?

我的 web.config

  <authentication mode="Forms">
    <forms loginUrl="Login.aspx" timeout="10"/>
  </authentication>

我已经阅读了 ASP.Net MVC 中的 LDAP 身份验证, 但是在成员资格提供程序中,他们写了连接、密码和用户名。

我应该怎么办?

4

2 回答 2

1

Like the answer there says:

The connection protection, user name and pwd are for the account that has access to query AD on behalf of the system. Depending on the security of your network this may have to be setup or you won't be able to query AD to authenticate the user.

It depends on the configuration of the server how you should authenticate.

于 2013-06-25T10:55:34.863 回答
1

如果您需要做的只是验证用户是否存在并且密码有效,则可以使用如下内容:参数是域名、用户 ID 和用户密码。由于我们没有查询任何内容,因此非管理员权限是可以的。

public static bool LogonValid(string ldapDomain, string userName, string password) {
    DirectoryEntry de = new DirectoryEntry(@"LDAP://" + ldapDomain, userName, password);

  try {
    object o = de.NativeObject;
    return true;
  }
    catch (Exception ex) {
    logger.Error(ex.ToString());
    return false;
  }
}

可能有原因表明这不适用于所有情况,但到目前为止它对我有用。

于 2013-06-25T18:35:28.490 回答