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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:38:28+00:00 2026-05-24T12:38:28+00:00

Hi i want to create a system user in window server 2003 active directory

  • 0

Hi i want to create a system user in window server 2003 active directory for which i use following C# code ,

 DirectoryEntry AD = new DirectoryEntry("WinNT://"+Environment.MachineName+",computer");

            DirectoryEntry NewUser = AD.Children.Add(username, "user");

            NewUser.Invoke("SetPassword", new object[] { password });

            NewUser.Invoke("Put", new object[] { "Description", "Test User from .NET"});

            NewUser.CommitChanges();

            DirectoryEntry grp;

            grp = AD.Children.Find("Guests", "group");

            if (grp != null)
            {
                grp.Invoke("Add", new object[] { NewUser.Path.ToString() });
            }

this code makes user when i run this application locally on visualy studio web engine but when i deploy this application on iis on window server 2003 this will give exception

Exception:

General Access Denied Error

kindly help me what im doing wrong which permission is required to create user in window server and how we give this perssion. thanks.

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

    Look at System.DirectoryServices.AccountManagement namespace. Utilizing classes from it you can do this in such way:

    using (var context = new PrincipalContext(ContextType.Machine, "MachineName", "AdminUserName", "AdminPassword"))
    {
        UserPrincipal user = new UserPrincipal(context, username, password, true);
        user.Description = "Test User from .NET";
        user.Save();
    
        var guestGroup = GroupPrincipal.FindByIdentity(context, "Guests");
        if (guestGroup != null)
        {
            guestGroup.Members.Add(user);
            guestGroup.Save();
        }
    }
    

    Also, you may configure impersonation on your application and skip all parameters in the PrincipalContext constructor exception the first one if this functionality allowed for administrators only.

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

Sidebar

Related Questions

I want to create a PNG file from a System.Drawing.Bitmap with the colours defined
I am trying to create a conversations based messaging system. I want to group
I want to create a simple http proxy server that does some very basic
I want to create a draggable and resizable window in JavaScript for cross browser
I want to create a small helpdesk ticket control system at work, that would
I am having issues getting the groups from Active Directory via System.DirectoryServices Originally I
Given a Java Servlet (running on a Windows server) which creates a new process
I want to create a window and show some image display (like animation based
Possible Duplicate: winapi CreateWindowEx -> create button with user system styles? Hi, I am
I want to create a windows service that would start before user can login.

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.