System.DirectoryServices.Direc ... [英] System.DirectoryServices.Direc...
问题描述
我遇到一些奇怪的错误,我的代码在开发服务器下可以正常运行,但是当我尝试将其发布到本地服务器上时,我遇到了这个错误.
System.DirectoryServices.DirectoryServicesCOMException:登录失败:用户名未知或密码错误.
I am getting some weird error, my code run perfectly under development server but when i am trying to publish it on my local server i am getting this error.
System.DirectoryServices.DirectoryServicesCOMException: Logon failure: unknown user name or bad password.
[DirectoryServicesCOMException (0x8007052e): Logon failure: unknown user name or bad password.
]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +439513
System.DirectoryServices.DirectoryEntry.Bind() +36
System.DirectoryServices.DirectoryEntry.get_SchemaEntry() +33
等
我的代码
and so on
My Code
string temp = Environment.GetEnvironmentVariable("USERNAME");
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "domain.com", "dc=domain, dc=com");
UserPrincipal up = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, temp);
if (up != null)
{
PrincipalSearchResult<Principal> Results = up.GetAuthorizationGroups();
foreach (Principal Result in Results)
{
if (Result.Name == "Users")
{
ClientScript.RegisterStartupScript(typeof(Page), "SymbolError",
"<script type=''text/javascript''>displayvideo();</script>");
}
}
}
我正在尝试使用Windows登录用户名来知道哪个组用户是...
我需要在Web配置中设置一些设置吗?
在LDAP和Windows身份验证方面,我完全是Noive..
请帮我这个..
谢谢
Parth
I am trying to use windows login username to know in which group user is ...
Do i need to set some setting in web config ???
I am completely Noive in term of LDAP and windows authentication ..
Please Help me on this ..
Thanks
Parth
推荐答案
您的Web应用程序可能不在用户上下文中运行,而是在其自身上下文中运行. LDAP中不存在您的Web应用程序所运行的帐户,因此无法登录以查询LDAP.您可能需要更新应用程序池,以便在LDAP知道并信任的帐户下运行.
Your web application is likely not running under the user''s context, but under it''s own context. The account that your web application is running under does not exist in LDAP and therefore cannot login to query LDAP. You may need to update your app pool to run under an account that LDAP knows and trusts.
这篇关于System.DirectoryServices.Direc ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!