Note: To add or read properties from an Active Directory group you need to have special username and password like an Active Directory admin.
DirectoryEntry addGroup;
string folderPath = "LDAP://CN="+grpName+"OU=”+FolderName+”,OU=Groups,DC=aaaaa,DC=com";
addGroup = new DirectoryEntry(folderPath, "Spluser", "password");
string usrId = “myUserID”;
string usrPath = "LDAP://CN="+usrId+”,OU=UserAccounts,DC=aaaaa,DC=com";
DirectoryEntry addUser;
addUser = new DirectoryEntry(usrPath);
if((chkGroupExistence(addGroup) == true)&&(chkUserExistence(addGroup, usrId) == false))
{
try
{
addGroup.Invoke("Add", new object[] { addUser.Path.ToString() });
}
catch (Exception)
{
LblSuccessMsg.Text = "User could not be added to the Group. ";
}
}
Leave your comments below.
Leave your comments below.
No comments:
Post a Comment