Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. D A

D A

Scheduled Pinned Locked Moved Visual Basic
databasetutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JR212
    wrote on last edited by
    #1

    Hi, I found this code on the internet. but now I want to know of a member is a group or a normal login. Someone has an idee how to find this info? Jan

    Set cmd = CreateObject("ADODB.Command")
    Set cn = CreateObject("ADODB.Connection")
    Set rs = CreateObject("ADODB.Recordset")

    cn.Open "Provider=ADsDSOObject;"

    cmd.CommandText = "SELECT adspath,cn from 'LDAP://" & getNC & _
    "' WHERE objectCategory = 'Group' and cn = '" & groupname & "'"

    cmd.activeconnection = cn

    Set rs = cmd.Execute

    '
    '****
    ' process the results of the query into our arrays for later
    '****
    '

    i = 0
    While rs.EOF <> True And rs.bof <> True
    grouppaths(i) = rs.fields("adspath").Value
    groupnames(i) = rs.fields("cn").Value
    rs.movenext
    i = i + 1
    Wend

    cn.Close

    If i = 0 Then
    MsgBox "Nothing Found, Exiting"
    Exit Sub
    End If

    Application.StatusBar = "Records Found..." & i

    '
    '****
    ' Turn off updates and calculations
    '****
    '
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    Application.DisplayStatusBar = True

    '
    '****
    ' found something so create the output files and write the headers
    '****
    '

    Application.StatusBar = "Creating Worksheet headers..."

    If i > 0 Then
    Set objsheet = Worksheets(blad)
    For h = 1 To 2 '1 To numheader2
    objsheet.Cells(1, h) = headers2(h)
    objsheet.Cells(1, h).Font.Bold = True
    Next
    End If

    '
    '****
    ' now process each group found and extract all members
    '****
    '

    cl = 1 'count lines
    gl = 1 'group lines

    Application.StatusBar = "Populating Worksheets..."

    For j = 0 To i - 1
    Application.StatusBar = "Writing Group " & j & " of " & i

    Set objgroup = GetObject(grouppaths(j))
    
    cl = cl + 1
    groupname.Offset(, 1) = objgroup.Members.Count
    c = objgroup.Members.Count
    g = 0
    Set objsheet = Worksheets(blad)
    If objgroup.Members.Count > 0 Then
        For Each objmember In objgroup.Members
            g = g + 1
            Application.StatusBar = "Writing Group Details " & g & " of " & c
    
            gl = gl + 1
            objsheet.Cells(gl, 1).Value = groupnames(j)
            objsheet.Cells(gl, 2).Value = Right(objmember.name, Len(objmember.name) - 3)
            objsheet.Cells(gl, 3).Value = objmember.OperatingSystem
            objsheet.Cells(gl, 4).Value = objmember.distinguishedName
        Next
    Else
        gl = gl + 1
        objsheet.Cells(gl, 1).Value = groupnames(j)
        For h = 2 To 2
    
    D 1 Reply Last reply
    0
    • J JR212

      Hi, I found this code on the internet. but now I want to know of a member is a group or a normal login. Someone has an idee how to find this info? Jan

      Set cmd = CreateObject("ADODB.Command")
      Set cn = CreateObject("ADODB.Connection")
      Set rs = CreateObject("ADODB.Recordset")

      cn.Open "Provider=ADsDSOObject;"

      cmd.CommandText = "SELECT adspath,cn from 'LDAP://" & getNC & _
      "' WHERE objectCategory = 'Group' and cn = '" & groupname & "'"

      cmd.activeconnection = cn

      Set rs = cmd.Execute

      '
      '****
      ' process the results of the query into our arrays for later
      '****
      '

      i = 0
      While rs.EOF <> True And rs.bof <> True
      grouppaths(i) = rs.fields("adspath").Value
      groupnames(i) = rs.fields("cn").Value
      rs.movenext
      i = i + 1
      Wend

      cn.Close

      If i = 0 Then
      MsgBox "Nothing Found, Exiting"
      Exit Sub
      End If

      Application.StatusBar = "Records Found..." & i

      '
      '****
      ' Turn off updates and calculations
      '****
      '
      Application.ScreenUpdating = False
      Application.Calculation = xlCalculationManual
      Application.DisplayStatusBar = True

      '
      '****
      ' found something so create the output files and write the headers
      '****
      '

      Application.StatusBar = "Creating Worksheet headers..."

      If i > 0 Then
      Set objsheet = Worksheets(blad)
      For h = 1 To 2 '1 To numheader2
      objsheet.Cells(1, h) = headers2(h)
      objsheet.Cells(1, h).Font.Bold = True
      Next
      End If

      '
      '****
      ' now process each group found and extract all members
      '****
      '

      cl = 1 'count lines
      gl = 1 'group lines

      Application.StatusBar = "Populating Worksheets..."

      For j = 0 To i - 1
      Application.StatusBar = "Writing Group " & j & " of " & i

      Set objgroup = GetObject(grouppaths(j))
      
      cl = cl + 1
      groupname.Offset(, 1) = objgroup.Members.Count
      c = objgroup.Members.Count
      g = 0
      Set objsheet = Worksheets(blad)
      If objgroup.Members.Count > 0 Then
          For Each objmember In objgroup.Members
              g = g + 1
              Application.StatusBar = "Writing Group Details " & g & " of " & c
      
              gl = gl + 1
              objsheet.Cells(gl, 1).Value = groupnames(j)
              objsheet.Cells(gl, 2).Value = Right(objmember.name, Len(objmember.name) - 3)
              objsheet.Cells(gl, 3).Value = objmember.OperatingSystem
              objsheet.Cells(gl, 4).Value = objmember.distinguishedName
          Next
      Else
          gl = gl + 1
          objsheet.Cells(gl, 1).Value = groupnames(j)
          For h = 2 To 2
      
      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      What do you mean by "member of a group" and a "normal login". Those concepts don't have anything to do with each other. Also, you might want to study the code you downloaded. Nobody is going to write your code for you and fix whatever is wrong or what you want in this script.

      A guide to posting questions on CodeProject

      Click this: Asking questions is a skill. Seriously, do it.
      Dave Kreskowiak

      J 1 Reply Last reply
      0
      • D Dave Kreskowiak

        What do you mean by "member of a group" and a "normal login". Those concepts don't have anything to do with each other. Also, you might want to study the code you downloaded. Nobody is going to write your code for you and fix whatever is wrong or what you want in this script.

        A guide to posting questions on CodeProject

        Click this: Asking questions is a skill. Seriously, do it.
        Dave Kreskowiak

        J Offline
        J Offline
        JR212
        wrote on last edited by
        #3

        I have used some wrong word i guess :) inside a AD group there can be another AD (sub)group now I want to know of the "children" in a group are simply accounts or (sub)groups example: in a big firm there a employers with different languages (in Belgium nlb, FRb end geb) in these 3 groups you have all workers of the firm so we've created a group with 3 subgroups and automatic into that big group that have only 3 subgroups, practicaly that group contains ±40000 accounts Jan

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups