Click here to Skip to main content
16,020,305 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to read all members from a certain NTFS group. So far I have this code, but it doesn't work. (It works just to get the names ( name& surname)) I want to get the usernames



VB
Dim dsGrupi As DataSet = GetGrupi()
Dim db As New dbGate
For i = 0 To dsGrupi.Tables(0).Rows.Count - 1

    search.Filter = [String].Format("(cn={0})", dsGrupi.Tables(0).Rows(i)(0).Trim())
    search.PropertiesToLoad.Add("samaccountname")
    search.PropertiesToLoad.Add("member")
    search.PropertiesToLoad.Add("description")
    result = search.FindOne()

    If result IsNot Nothing Then
        Dim dn As [String]
        Dim clenovi As [String] = ""
        Dim equalsIndex As Integer
        Dim commaIndex As Integer
        Dim user As String = ""

        For counter As Integer = 0 To result.Properties("samaccountname").Count - 1
            dn = result.Properties("samaccountname")(counter).ToString()
            equalsIndex = dn.IndexOf("=", 1)
            commaIndex = dn.IndexOf(",", 1)
            user += dn.Substring(equalsIndex + 1, commaIndex - equalsIndex - 1) + ";"

        Next

        txtUsers.Text = user

    Else
        MessageBox.Show("Group doesnt exists!")
    End If




The error I get is this: Index was out of range. Must be non-negative and less than the size of the collection.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900