获取当前域中的所有组名,即使用户不在该组中?

时间:2019-01-07 15:27:04

标签: vb.net active-directory

我当前正在尝试将组权限添加到网站,并具有一个下拉列表以将组添加到所述权限。目前,我可以找到我所在的所有群组,但是即使我不在群组中,也无法找到显示域中所有群组的方法。以下是我当前的工作代码。感谢任何帮助!

Private Sub PopulateDropDownLists()
    Dim context As WebCMEntities.WebCMModelContainer
    Dim strGroupName As String


    context = New WebCMEntities.WebCMModelContainer

    ddlAddAuthorizedWebsites.DataSource = context.WebCMWebsites.OrderBy(Function(x) x.WebsiteName).ToList
    ddlAddAuthorizedWebsites.DataTextField = "WebsiteName"
    ddlAddAuthorizedWebsites.DataValueField = "WebsiteID"
    ddlAddAuthorizedWebsites.DataBind()

    For Each tmpGroup In System.Security.Principal.WindowsIdentity.GetCurrent().Groups
        strGroupName = FormatGroupName(tmpGroup.Translate(GetType(System.Security.Principal.NTAccount)).ToString)
        ddlAddGroups.Items.Add(New ListItem(strGroupName))
    Next


End Sub

0 个答案:

没有答案