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 7610021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:19:06+00:00 2026-05-31T01:19:06+00:00

I am writing a csharp windows form application which attempts to check for the

  • 0

I am writing a csharp windows form application which attempts to check for the existence of a local account and if found set the password on it. A couple of key points:

  • I’m doing this for local accounts – NOT Active Directory accounts. The machines are not members of a windows AD domain.

  • I HAVE to use setpassword not changepassword as change password requires you to know the previous password which in some cases I do not. Setpassword is supposed to allow you to select a new password without having to know the old one

  • The application will be run by approximately 50 users using a variety of OS’s from Windows XP all the way up to Windows Server 2008 R2. Because I can’t predict what operating system and version of .net will be available I have set my target framework as .net 2.0.

  • I am expecting my user to be running as an administrator presently so I don’t think permissions are an issue. I can create uses just fine I just can’t set password on an existing account.

Here’s my code:

    public void VerifiyAccount()
    {
        String username = "specialaccount";
        String password = "SuperSecretPassw0rd!";

        if (CheckIfAccountExists(username))
        {
            MessageBox.Show("User Account all ready exists.");
            SetUserPassword(password);

        }
        else
        {
            MessageBox.Show("User Account does not exist");
            CreateUserAccount(username, password);
        }
    }

    public void SetUserPassword(string newPassword)
    {
        try
        {
            DirectoryEntry hostMachineDirectory = new DirectoryEntry("WinNT://" + Environment.MachineName + ", specialaccount");
            hostMachineDirectory.Invoke("SetPassword", newPassword);
            hostMachineDirectory.CommitChanges();
            hostMachineDirectory.Close();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

    }

Here’s the error I am receiving:


Unknown error (0x80005000)

OK

I can’t figure out why I’m getting the above error and despite googling and searching stack overflow I can’t find any explanation. Most examples I can find revolve around connecting to Active Directory – not local accounts. Or are using newer .net 4.0 features. I have to believe that if I can create an account I should be able to set the password on an account. Any ideas or suggestions on what I might be doing wrong?

Thanks
Brad

  • 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-05-31T01:19:08+00:00Added an answer on May 31, 2026 at 1:19 am

    I’ve run in to similarly obfuscated errors when using ActiveDirectory libraries. What I’ve found to be immensely helpful is using the Microsoft Network Monitor to track messages being sent to/from LDAP. Usually the error message being sent back has much more detail.

    EDIT: I would recommend the following to help debug your communication issues:

    • Place a breakpoint and run your app to where you CommitChanges
    • Fire-up the Microsoft Network Monitor (start the capture)
    • Execute the CommitChanges line
    • Stop the current capture in the Microsoft Network Monitor

    At this point you can scroll through the messages to see where your calls occurred.

    EDIT2: Here’s a reference to the DirectoryEntry.Path. It shows the WinNT formatting for connecting to a user as:

    WinNT:// < domain name> / < computer name > / < user name >

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

Sidebar

Related Questions

Writing a .NET DLL how do I find Application.ProductName ? EDIT: Obviously, importing Windows.Forms
i use some pictures in my 'MainForm' And My Windows Application was writing by
When writing a web application which allows the upload of files, one must be
Writing the code for the user authentication portion of a web site (including account
Writing my first Linq application, and I'm trying to find the best way to
I trying to create a bat file using csharp which contains some commands. So
Writing an iPhone app in which I want to save the user the grief
Writing a program in which I need to split strings from a struct linked
I am writing a WPF application, and one feature I want to implement is
Writing an iPhone app in Objective-C, I have a date in string form (in

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.