Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9245289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:14:06+00:00 2026-06-18T09:14:06+00:00

I have a weird scenario here. My app connects to a fileserver to list

  • 0

I have a weird scenario here. My app connects to a fileserver to list the files from a directory using UNC. It has been working for the past couple of years without any problem. Recently, my network admin rebooted the server as a result of which I started getting LogonUser : Unknown user or bad password error. As per the network admin, everything is set up correctly for the domain user account. The username and password are all correct. Is there anything I need to change in the code below?

const int LOGON32_LOGON_INTERACTIVE = 2;
const int LOGON32_LOGON_NETWORK = 3;
const int LOGON32_LOGON_BATCH = 4;
const int LOGON32_LOGON_SERVICE = 5;
const int LOGON32_LOGON_UNLOCK = 7;
const int LOGON32_LOGON_NETWORK_CLEARTEXT = 8;
const int LOGON32_LOGON_NEW_CREDENTIALS = 9;
const int LOGON32_PROVIDER_DEFAULT = 0;

[DllImport("advapi32.dll", SetLastError = true)]
public static extern int LogonUser(
    string lpszUsername,
    string lpszDomain,
    string lpszPassword,
    int dwLogonType,
    int dwLogonProvider,
    out IntPtr phToken
    );
[DllImport("advapi32.dll", SetLastError = true)]
public static extern int ImpersonateLoggedOnUser(
    IntPtr hToken
);

[DllImport("advapi32.dll", SetLastError = true)]
static extern int RevertToSelf();

[DllImport("kernel32.dll", SetLastError = true)]
static extern int CloseHandle(IntPtr hObject);
int TResult = LogonUser(ConfigurationManager.AppSettings["ServerUserName"].ToString(), @"\\server\folder", ConfigurationManager.AppSettings["ServerPassword"].ToString(), LOGON32_LOGON_NEW_CREDENTIALS, LOGON32_PROVIDER_DEFAULT, out lnToken);

Please advise on what else I should be checking with my network admin. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:14:07+00:00Added an answer on June 18, 2026 at 9:14 am

    I don’t see anything inherently wrong with the code that you are executing. So, I’m not certain why this would suddenly STOP working. However, if you are open to a little re-factoring there appear to be others that have run into similar issues. One of the below answers should give you the insight you need.

    How to Impersonate a user for a file copy over the network when dns or netbios is not available

    Accessing Password Protected Network Drives in Windows in C#?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very weird bug here, this is the scenario; -I click on
I have a quite weird scenario: I have a WPF application installed using my
I have a weird scinario. I have been using $.ajax() to make ajax calls
Ok I have a bit of a weird scenario, and I can't change the
Well this is weird let me describe the scenario I have this mailer define
I have a weird issue with creating an Bitmap in C++. I'm using the
I have another weird problem which I have not been able to solve in
I have a weird scenario where I need to convert several million java.lang.Long s
I have this weird issue with special characters. In JSP, I am using field
Have a weird scenario where the ADO.Net keep returning SQLite error. Insufficient parameters supplied

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.