繁体   English   中英

C# Active Directory - 用户名和密码不正确,但详细信息实际上是正确的

[英]C# Active Directory - Incorrect Username and Password but details are actually correct

Active Directory 和 C# 存在问题。 我收到一个间歇性错误,指出“用户名或密码不正确。”。 但是,我知道登录详细信息是正确的,因为它在 VS 中本地工作。 它似乎每次都不会出现在 web 服务器上。

错误:

The user name or password is incorrect.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.DirectoryServices.DirectoryServicesCOMException: The user name or password is incorrect.

我用于存储与 LDAP 的连接的代码,出于安全原因隐藏了位:

    public static DirectoryEntry GetDirectoryEntryWithGc()
    {
        var de = new DirectoryEntry("GC://dc=TEXT,dc=TEXT,dc=TEXT");
        de.AuthenticationType = AuthenticationTypes.Secure;
        de.Username = "USERNAME";
        de.Password = "PASSWORD";
        return de;
    }

如前所述,在本地工作并且是间歇性的。 有人有这方面的经验吗?

这只是一种猜测,但您的 AD 林中是否有多个域? 您是否在"USERNAME"中包含域名(即"DOMAIN\USERNAME" )?

在不指定服务器名称的情况下使用GC://可以从林中的任何域连接到服务器。 如果您没有在用户名中指定域名,那么它将假定用户名来自服务器的域,但情况可能并非如此。

如果我在这方面是正确的,那么您可以通过在用户名中包含域名来解决问题:

de.Username = "DOMAIN\USERNAME";

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM