출처 : http://help.wugnet.com/windows2/Change-group-user-AD-ftopict486801.html
다른건 볼거 없고,
oGroupToRemove.Properties["member"].Remove("CN=" + LoginID);
여기처럼 properties["member"] 를 통해 AD Group 의 사용자를 가져올 수 있다.
--------------------------------------------------------------------------------------------------
coming "The server is unwilling to process the request. (Exception
from HRESULT: 0x80072035) trying to remove a user from group". I'm
giving a code block here:
//change group membership
//first remove user from other groups
ArrayList arlGroups = GetGroups(LoginID, false);
DirectoryEntry oGroupToRemove = new DirectoryEntry();
for (int i = 0; i < arlGroups.Count; i++)
{
string sGroup = arlGroups.ToString();
sGroup = sGroup.Substring(0, sGroup.IndexOf(","));
string[] split = sGroup.Split(new Char[] { '=' });
sGroup = split[1].ToString();
oGroupToRemove = oDirEntry.Children.Find("CN=" + sGroup, "group");
//THE NEXT LINE IS CAUSING THE EXCEPTION
oGroupToRemove.Properties["member"].Remove("CN=" + LoginID);
oGroupToRemove.CommitChanges();
oGroupToRemove.Close();
}
//add member to the given group
DirectoryEntry oGroup = new DirectoryEntry();
oGroup = oDirEntry.Children.Find("CN=" + GroupName, "group");
if (oGroup != null)
{
oGroup.Invoke("Add", new object[] { oUser.Path.ToString() });
}
oGroup.CommitChanges();
oGroup.Close();
Please help me as soon as possible.
Thnx in advance
다른건 볼거 없고,
oGroupToRemove.Properties["member"].Remove("CN=" + LoginID);
여기처럼 properties["member"] 를 통해 AD Group 의 사용자를 가져올 수 있다.
--------------------------------------------------------------------------------------------------
coming "The server is unwilling to process the request. (Exception
from HRESULT: 0x80072035) trying to remove a user from group". I'm
giving a code block here:
//change group membership
//first remove user from other groups
ArrayList arlGroups = GetGroups(LoginID, false);
DirectoryEntry oGroupToRemove = new DirectoryEntry();
for (int i = 0; i < arlGroups.Count; i++)
{
string sGroup = arlGroups.ToString();
sGroup = sGroup.Substring(0, sGroup.IndexOf(","));
string[] split = sGroup.Split(new Char[] { '=' });
sGroup = split[1].ToString();
oGroupToRemove = oDirEntry.Children.Find("CN=" + sGroup, "group");
//THE NEXT LINE IS CAUSING THE EXCEPTION
oGroupToRemove.Properties["member"].Remove("CN=" + LoginID);
oGroupToRemove.CommitChanges();
oGroupToRemove.Close();
}
//add member to the given group
DirectoryEntry oGroup = new DirectoryEntry();
oGroup = oDirEntry.Children.Find("CN=" + GroupName, "group");
if (oGroup != null)
{
oGroup.Invoke("Add", new object[] { oUser.Path.ToString() });
}
oGroup.CommitChanges();
oGroup.Close();
Please help me as soon as possible.
Thnx in advance
'.NET > C#' 카테고리의 다른 글
ADHelper - An Active Directory Class (0) | 2009.08.17 |
---|---|
C# - Dynamically Invoke Web Service At Runtime (0) | 2009.08.13 |
.NET Framework 3.5의 디렉터리 보안 주체 관리 (0) | 2009.04.01 |
Debugging windows service Onstart (0) | 2009.03.27 |
How to create a mailbox-enabled recipient by using Visual C# (0) | 2009.03.16 |