Need to put data from SQL Server into Active Directory

Posted on 2004-08-26
Last Modified: 2010-04-15

Just came from the Windows2003 section and it seems that there is nothing usefull to accompligh the job without creating a custom prgram.

So, I need code snippet to help me get on track faster than on my own.
I know that there is a directory class library in the framework.
It would be helpfull to get input from someone who had to use it.

Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

sohilm earned 500 total points
ID: 11903922
What exactly are you trying to do?

   Here is an example on how to use system.directoryservices to create a user

using System;
using System.DirectoryServices;

namespace ADAM_Examples
    class CreateUser
        /// <summary>
        /// Create ADAM User.
        /// </summary>
        static void Main()
            DirectoryEntry objADAM;       // Binding object.
            DirectoryEntry objUser;       // User object.
            string strDisplayName;        // Display name of user.
            string strPath;               // Binding path.
            string strUser;               // User to create.
            string strUserPrincipalName;  // Principal name of user.

            // Construct the binding string.
            strPath = "LDAP://localhost:389/O=Fabrikam,C=US";

            Console.WriteLine("Bind to: {0}", strPath);

            // Get ADAM object.
                objADAM = new DirectoryEntry(strPath);
            catch (Exception e)
                Console.WriteLine("Error:   Bind failed.");
                Console.WriteLine("         {0}", e.Message);

            // Specify User.
            strUser = "CN=TestUser";
            strDisplayName = "Test User";
            strUserPrincipalName = "TestUser@Fabrikam.Us";
            Console.WriteLine("Create:  {0}", strUser);

            // Create User.
                objUser = objADAM.Children.Add(strUser, "user");
            catch (Exception e)
                Console.WriteLine("Error:   Create failed.");
                Console.WriteLine("         {0}", e.Message);

            // Output User attributes.
            Console.WriteLine("Success: Create succeeded.");
            Console.WriteLine("Name:    {0}", objUser.Name);
            Console.WriteLine("         {0}",
            Console.WriteLine("         {0}",

I suggest getting the LDP.exe utiltiy from the windows 2003 server support tools to checkout what properties you can modify.

I hop this helps.



Author Comment

by:Yann de Champlain, PMP
ID: 11904924
Thank you.  It will be enough.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question