Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default LDAP Query Not working For All Groups

I wrote an LDAP query using VBA in Excel. It is suppossed to return all the
groups to which a user belongs, directrly or indirectly. However, the
recursion only occurs on smome groups, not others. I can not for the life of
me figure out why. Can anybody see any errors in the code below? Thanks so
much if you can!

Dim y
Dim strSpacer
Sub ldap()
Sheets("Sheet1").Select

'Queries AD for all User Names
On Error Resume Next
Set con = CreateObject("ADODB.Connection")
Set cmd = CreateObject("ADODB.command")
Set rst = CreateObject("ADODB.RecordSet")

'defines the type of DB we are connecting to
con.Provider = "ADsDSOObject"
con.Open

cmd.ActiveConnection = con
cmd.Properties("Page Size") = 20000
'Submit the query
cmd.CommandText = "<LDAP://DC=capitol,DC=local;(cn=Gary Stockton);name,
ADsPath"

Set rst = cmd.Execute
y = 2
Do Until rst.EOF
Range("a" & y).Select
Selection.Font.Bold = True
Range("a" & y).Value = rst.Fields("name")
Range("b" & y).Value = rst.Fields("ADsPath")
Range("c" & y).Value = rst.Fields("class")
ListGroups
rst.MoveNext
y = y + 1

Loop

End Sub

Private Sub ListGroups()
On Error Resume Next
Set Object = GetObject(Range("B" & y).Value)
objMemberOf = Object.GetEx("MemberOf")
strSpacer = strSpacer & " "
For Each objGroup In Object.memberOf
If Not objGroup = Empty Then
y = y + 1
strQuery = "LDAP://" & objGroup
Set Object = GetObject(strQuery)
Range("a" & y).Value = strSpacer & Mid(Object.Name, 4,
Len(Object.Name) - 3)
Range("b" & y).Value = Object.ADsPath
ListGroups
End If
Next
strSpacer = Left(strSpacer, Len(strSpacer) - 6)
End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Discussion Groups Home - Search not working pshepard Excel Worksheet Functions 1 October 10th 08 11:00 AM
Working days in MS Query mcquam Excel Discussion (Misc queries) 1 June 6th 08 03:06 PM
Web query has stopped working... andrewm27 Excel Discussion (Misc queries) 0 April 20th 06 05:28 AM
LDAP Query Pam Carney Excel Programming 0 July 31st 03 03:18 PM


All times are GMT +1. The time now is 08:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"