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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:27:27+00:00 2026-05-28T06:27:27+00:00

I am using VS2005 .NET 2.0 C#. I am currently referencing to a website

  • 0

I am using VS2005 .NET 2.0 C#.

I am currently referencing to a website on implementing AD user management on asp webpage.

I have seen one method which adds user to group.

However, there are some parameters which I do not understand and know what to replace with.

Below is the method provided:

public void AddToGroup(string userDn, string groupDn)
{
    try
    {
        DirectoryEntry dirEntry = new DirectoryEntry("LDAP://" + groupDn);
        dirEntry.Properties["member"].Add(userDn);
        dirEntry.CommitChanges();
        dirEntry.Close();
    }
    catch (System.DirectoryServices.DirectoryServicesCOMException E)
    {
        //doSomething with E.Message.ToString();

    }
}

userDn and groupDn has been explained but I still do not know what to fill in it

userDn: the distinguishedName of the user: CN=user, OU=USERS, DC=contoso, DC=com
groupDn: the distinguishedName of the group: CN=group,OU=GROUPS,DC=contoso,DC=com

May I know what are the 2 parameters and where can I get them from?

  • 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-28T06:27:28+00:00Added an answer on May 28, 2026 at 6:27 am

    A directory is a tree in wich each object is a node. Each object in this tre as got a Distinguished Name (DN), it looks a bit like the DNS name of a computer. You can have look to your Active-Directory with an LDAP vision using LDP.EXE tool from the ressource kit (or natively installes on W2K8). You’ll find here under one LDAP AD vision

    LDP vision of an AD

    for

    MMC vision of an AD

    How can you find them :

    For the group :

    DirectoryEntry deBase = new DirectoryEntry("LDAP://dom.fr/dc=dom,dc=fr");
    /* Directory Search for a group
     */
    DirectorySearcher dsLookForGrp = new DirectorySearcher(deBase);
    dsLookForGrp.Filter = String.Format("(cn={0})", "yourgroup");
    dsLookForGrp.SearchScope = SearchScope.Subtree;
    dsLookForGrp.PropertiesToLoad.Add("distinguishedName");
    SearchResult srcGrp = dsLookForGrp.FindOne();
    
    string groupDN = srcGrp.Properties["distinguishedName"][0];
    

    For the user :

    /* Directory Search
     */
    DirectorySearcher dsLookForUser = new DirectorySearcher(deBase);
    dsLookForUser.Filter = String.Format("(&(objectCategory=person)(sAMAccountName={0}))", YourUser);
    dsLookForUser.SearchScope = SearchScope.Subtree;
    dsLookForUser.PropertiesToLoad.Add("distinguishedName");
    dsLookForUser.PropertiesToLoad.Add("userPrincipalName  ");
    dsLookForUser.PropertiesToLoad.Add("sAMAccountName");
    SearchResult srcUser = dsLookForUser.FindOne();
    
    string userDN = srcUser .Properties["distinguishedName"][0];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using VS2005 .NET 2.0 C#. I am currently managing my user roles
I am using VS2005 C# ASP.NET. I have a webform which contains a list
I am using VS2005 C# ASP.NET. I have a .aspx page with a script
I'm currently using VS2005 Profesional and .NET 2.0, and since our project is rather
Im currently using vs2008 with asp.net mvc framework for web development. Im missing a
I have a Windows 7 machine on which I am using VS2005. .Net 2.0
Am using VS2008 ASP.Net Web Forms have a detailsview, databound to web service reference
Currently I'm looking at a problem with web references in vs2005 .net I have
I'm using VS 2005 in a VB.Net WinForms application. I have a custom User
I'm currently developping to application, one using the ODP.Net 9.2 and the other one

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.