0

我正在使用下面的代码来获取用户组,但我不确定如何编写代码来说明如果用户在“TestGroup”中,如果不重定向页面,则执行某些操作?

   Dim resEnt As SearchResult
        Try
            For Each resEnt In mySearcher.FindAll()
                LabelUser.Text = resEnt.GetDirectoryEntry.Properties.Item("DisplayName").Value
                LabelLocation.Text = resEnt.GetDirectoryEntry.Properties.Item("SystemUserLocation").Value
                LabelState.Text = resEnt.GetDirectoryEntry.Properties.Item("st").Value
                LabelCountry.Text = resEnt.GetDirectoryEntry.Properties.Item("c").Value

                Dim result As SearchResult = mySearcher.FindOne()
                If (result Is Nothing) Then
                Else

                    Dim groupColl As Object
                    For Each groupColl In resEnt.Properties("memberof")
                        Dim GroupArray As Array = groupColl.split(",")
                        Select Case GroupArray(0).replace("CN=", "")
                            Case "TestGroup"
                                'Continue loading page
                            Case Else
                                'Prevent page from loading????

                        End Select


                    Next groupColl
                End If
            Next
        Catch f As Exception
            Console.WriteLine(f.ToString)
        End Try
4

0 回答 0