버튼이있는 드롭 다운 목록에서 사용자를 삭제하고 싶습니다. 목록은 AD 사용자로 채워집니다. 아래 코드.C# 목록에서 버튼을 사용하여 사용자 삭제
private void generate_Combobox()
{
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
UserPrincipal qbeUser = new UserPrincipal(ctx);
PrincipalSearcher srch = new PrincipalSearcher(qbeUser);
foreach (var found in srch.FindAll())
{
UserPrincipal foundUser = found as UserPrincipal;
if (foundUser != null && foundUser.GivenName != null && foundUser.Surname != null)
{
cmb_Students.Items.Add(foundUser.GivenName + " " + foundUser.Surname + " " + "[" + foundUser.SamAccountName + "]");
}
}
}
이제 버튼에 문제가 있습니다. 사용자를 삭제하는 방법을 찾았지만 내 목록과 호환되는 방법을 모릅니다.
private void btn_DeleteStudent_Click(object sender, EventArgs e)
{
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, selectedUser);
if (user != null)
{
user.Delete();
}
그래서 질문은 무엇입니까? – Marusyk
AD에서 사용자를 삭제할 수 있도록 아래에 언급 된 방법을 드롭 다운 목록과 호환되게하려면 어떻게해야합니까? – Reynaert98