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

  • Home
  • SEARCH
  • 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 356441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:06:44+00:00 2026-05-12T12:06:44+00:00

I posted a question re LDAP account management, but after exploring this, it’s not

  • 0

I posted a question re LDAP account management, but after exploring this, it’s not what i’m after. I’ve managed to find two ways of creating users on a machine, and i find one is much neater than the other, however, i am uncertain how to convert the first option over to the second option entirely.

This was my first solution:

        Process MyProc = new Process();
        MyProc.StartInfo.WorkingDirectory = System.Environment.SystemDirectory;
        MyProc.StartInfo.FileName = "net.exe";
        MyProc.StartInfo.UseShellExecute = false;
        MyProc.StartInfo.RedirectStandardError = true;
        MyProc.StartInfo.RedirectStandardInput = true;
        MyProc.StartInfo.RedirectStandardOutput = true;
        MyProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

        MyProc.StartInfo.Arguments = string.Format(@" user {0} {1} /ADD /ACTIVE:YES /EXPIRES:NEVER /FULLNAME:{0}"" /PASSWORDCHG:NO /PASSWORDREQ:YES", username, password);

        MyProc.Start();
        MyProc.WaitForExit();
        int exit = MyProc.ExitCode;

        MyProc.Close();

        return exit == 0;

And this was my second (preffered) solution:

        DirectoryEntry root = GetDELocalRoot();
        DirectoryEntry user = root.Children.Add(username, "user");
        //TODO: Always Active
        //TODO: Never Expires
        //TODO: No Password Change
        //TODO: Password Required
        user.Properties["description"].Value = "Account for running the MicaService and handling updates.";
        user.Invoke("SetPassword", new object[] { password });

        user.CommitChanges();
        user.Close();

I would like to map all the settings in my TODO: from the first solution into my second neater solution.

I have tried the following line as well:

user.Properties["userAccountControl"].Value = ADS_USER_FLAG.ADS_UF_NORMAL_ACCOUNT | ADS_USER_FLAG.ADS_UF_PASSWD_CANT_CHANGE | ADS_USER_FLAG.ADS_UF_DONT_EXPIRE_PASSWD;

But this does not work as the property does not exist in cache.

NOTE: the GetDELocalRoot() = return new DirectoryEntry(“WinNT://” + Environment.MachineName);

Thanks for any input!

Regards

Tris

  • 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-12T12:06:44+00:00Added an answer on May 12, 2026 at 12:06 pm

    Check out my friend Richard Mueller’s web site which has lots of useful information and reference material on what those two providers – WinNT for local machine accounts vs. LDAP for network accounts – have to offer.

    There’s also a Excel sheeet with all attributes that the WinNT provider exposes – it’s a lot less than what the LDAP provider has, so I’m not sure if you’ll be able to set all the properties you’re looking for.

    Marc

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

Sidebar

Related Questions

i posted a question like this yesterday but I was not clear in the
I posted this question on Reddit Programming and did not get a single response.
This is an already posted question but I need to understand what is going
I posted a question similar to this earlier, however, after thinking about it and
I posted a question about this earlier, but I have more information now and
I'm sure this question HAS to have been asked, but after searching through the
i posted another question about this, but i think this one will be more
I posted this question on serverfault.com, but I had no answer, so I'm trying
I posted this question on MWS forum but, didn't get an answer. So, I'm
I posted this question on webmasters.stackexchange.com but no reply, so I thought I'd try

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.