[英]C# Active Directory - Incorrect Username and Password but details are actually correct
Issue with Active Directory & C#. Active Directory 和 C# 存在问题。 I'm getting an intermittent error stating that "The user name or password is incorrect.".
我收到一个间歇性错误,指出“用户名或密码不正确。”。 However, I know the login details are correct as it works Locally in VS.
但是,我知道登录详细信息是正确的,因为它在 VS 中本地工作。 It seemingly doesn't on the web server everytime.
它似乎每次都不会出现在 web 服务器上。
Error:错误:
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.
My code for storing the connection to the LDAP, bits hidden for security reasons:我用于存储与 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;
}
As mentioned, works Locally and is intermittent.如前所述,在本地工作并且是间歇性的。 Anyone any experience of this?
有人有这方面的经验吗?
This is just a guess, but is there more than one domain in your AD forest?这只是一种猜测,但您的 AD 林中是否有多个域? And are you including the domain name in
"USERNAME"
(ie "DOMAIN\USERNAME"
)?您是否在
"USERNAME"
中包含域名(即"DOMAIN\USERNAME"
)?
Using GC://
without specifying a server name can connect to a server from any of the domains in your forest.在不指定服务器名称的情况下使用
GC://
可以从林中的任何域连接到服务器。 If you did not specify the domain name in your username, then it will assume the username is from the server's domain, which may not be the case.如果您没有在用户名中指定域名,那么它将假定用户名来自服务器的域,但情况可能并非如此。
If I'm correct in this, then you can solve the issue by including the domain name with the username:如果我在这方面是正确的,那么您可以通过在用户名中包含域名来解决问题:
de.Username = "DOMAIN\USERNAME";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.