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?
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
for
How can you find them :
For the group :
For the user :