Need to put data from SQL Server into Active Directory

Posted on 2004-08-26
Medium Priority
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.

Question by:Yann de Champlain

Accepted Solution

sohilm earned 2000 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
ID: 11904924
Thank you.  It will be enough.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Suggested Courses

627 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