Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.




VB
[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>");
                        }
                    }
                 }


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
Posted

1 solution

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.
 
Share this answer
 
Comments
Laraa mackyn 21-Feb-13 23:54pm    
Is this required to be added in apppool identity custom account by setting username and password.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900