Logon failure: unknown user name or bad password RRS feed

  • Question

  • User1801871119 posted

    HI Folks,

    Here is my code. when i run using vs 2005 it works fine. but when i try to run using localhost/app/page.aspx it pops up with error.

    Logon failure: unknown user name or bad password.

    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: Logon failure: unknown user name or bad password.

    Source Error:

    Line 57: 
    Line 58:         'Make a serach result
    Line 59:         Dim sr As SearchResult = searcher.FindOne





    Dim dirObject As New DirectoryEntry(LDAP://ldap-server.eu.company.net)

    Dim searcher As New DirectorySearcher(dirObject)

    searcher.Filter = "sAMAccountName=" + "yds3k5k3"


    Dim sr As SearchResult = searcher.FindOne

    Dim strVal As String = sr.Properties("cn").Item(0).ToString


    please help.


    Friday, May 25, 2007 10:23 AM

All replies

  • User-1085945103 posted

    I also have the exact error does someone already figure this out.

    Tuesday, August 7, 2007 4:48 AM
  • User1801871119 posted

    check this out


    Wednesday, August 8, 2007 10:28 AM
  • User-495392788 posted

    if u have solution of this problem.


    Please give me.


    i am gating same problem

    : Logon failure: unknown user name or bad password


    Tuesday, January 20, 2009 8:48 AM
  • User43631563 posted

    When I am trying to move the file from one server to another, I am getting the above mentioned error.

    System.IO.File.Copy(f1.Path, sToFld )

    where f1.Path - source server

    sToFld - destination server

    I believe its happening since the user credentials are different for both the servers. I was thinking of impersoantion, but I am not sure if impersonation works for remote computer.

    Thanks for help in advance.


    Tuesday, July 28, 2009 1:39 PM
  • User-2009597737 posted

    Your directory entry needs a userid/password that can search the domain. Most probably it is using the IIS worker process. Get a set of credentials from the network group that you can set. The equvalent c# is

    DirectoryEntry.Username =  ; DirectoryEntry.Password=

    I don't think you need to load Property unless you are processing that seperately.

    Also the syntax: sr.Properties("cn").Item(0).ToString is not correet.  There is no Item.

    Simple: sr.Properties("cn").Value.ToString() should be.

    Tuesday, July 28, 2009 2:49 PM
  • User-696158525 posted


    I am facing the same problem in my application.
    I am trying to copy files from a server inside a folder in my application. In my development environment it works perfetly while when I publish my app in IIS in Server it generates me the error :

    Logon failure: unknown user name or bad password.

    I have tried with impersonate in web.config but nothing.
    Have anybody of you solved this issue? If yes please tell me how.


    Wednesday, September 16, 2009 4:22 AM
  • User1801871119 posted

    Try adding worker process in your web project folder on IIS.

    Remember you must be under the domain you are trying to access.


    try passing credentials in your code.(for testing puporses)

    Let me know..

    Wednesday, September 16, 2009 5:32 AM
  • User-2027253991 posted


    Did u find the solution for Logon Failure:Unknown user name or bad password?



    Friday, November 13, 2009 2:46 AM