Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 将主要用户列表复制到arraylist以使用arraylist.indexof。图书管理系统_Vb.net - Fatal编程技术网

Vb.net 将主要用户列表复制到arraylist以使用arraylist.indexof。图书管理系统

Vb.net 将主要用户列表复制到arraylist以使用arraylist.indexof。图书管理系统,vb.net,Vb.net,我所做的是遍历属于顶级组(通用报告)的所有组。然后我利用了GroupPrincipal.GetMembers(True),它将通过给定的组名递归。我测试用户是否在该组下退出,如果为真,我将组名放入arraylist中 我在GroupPrincipal.GetMembers中使用for-each-principal循环遍历每个返回的用户,查看它们是否存在 是否有方法将GroupPrincipal.GetMembers>中给定组的所有返回用户Principal.Name放入ArrayList?这将允

我所做的是遍历属于顶级组(通用报告)的所有组。然后我利用了
GroupPrincipal.GetMembers(True)
,它将通过给定的组名递归。我测试用户是否在该组下退出,如果为真,我将组名放入arraylist中

我在
GroupPrincipal.GetMembers
中使用for-each-principal循环遍历每个返回的用户,查看它们是否存在

是否有方法将
GroupPrincipal.GetMembers>中给定组的所有返回用户
Principal.Name
放入
ArrayList
?这将允许我使用
Arraylist1.IndexOf
搜索用户。这将比使用for-each构造遍历返回的列表快得多

谢谢

Sub RetAllMbrs(strUser As String)
    Dim oPC As PrincipalContext = GetPrincipalContext() '<- this is function somewhere else in the code
    Dim grp1 As GroupPrincipal = GroupPrincipal.FindByIdentity(oPC, IdentityType.Name, "Generic Reports")    ' return all groups under cr reports
    Dim usr As UserPrincipal = UserPrincipal.FindByIdentity(oPC, IdentityType.Name, "Joe User")
    strUser = usr.SamAccountName
    Dim al_GrpList As New ArrayList

    For Each gp As Principal In grp1.Members
      Dim strGroup As String = gp.Name
      If strGroup.Substring(0, 10).ToLower = "generic reports" Then  'only do groups
        Dim grp2 As GroupPrincipal = GroupPrincipal.FindByIdentity(oPC, IdentityType.Name, strGroup)    'return all items under group
        For Each p As Principal In grp2.GetMembers(True)    'recurse group and see if user present 
          Dim strSamAcct As String = p.SamAccountName
          If strSamAcct.ToLower = strUser.ToLower Then
            al_GrpList.Add(strGroup)
            Exit For
          End If
        Next
        grp2.Dispose()
      End If
    Next
    oPC.Dispose()
  End Sub
Sub-retralmbrs(strUser作为字符串)

Dim oPC As PrincipalContext=GetPrincipalContext()’根据循环中的逻辑,我认为将grp1成员移动到不同的构造中不会有任何好处,因为grp2成员基于grp1名称