D A
-
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
Wendcn.Close
If i = 0 Then
MsgBox "Nothing Found, Exiting"
Exit Sub
End IfApplication.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 linesApplication.StatusBar = "Populating Worksheets..."
For j = 0 To i - 1
Application.StatusBar = "Writing Group " & j & " of " & iSet 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
-
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
Wendcn.Close
If i = 0 Then
MsgBox "Nothing Found, Exiting"
Exit Sub
End IfApplication.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 linesApplication.StatusBar = "Populating Worksheets..."
For j = 0 To i - 1
Application.StatusBar = "Writing Group " & j & " of " & iSet 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
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 -
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 KreskowiakI 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