Hello,
I'd like to create a report in Reporting Services 2000 listing the
members of a given Active Directory group.
I found on the internet a vbs-script to retrieve the information
needed:
Set objGroup = GetObject("LDAP://CN=MyGroup,OU=MyOU,DC=MyDC")
For Each objUser in objGroup.Members
Wscript.Echo "Name: " & objUser.DisplayName
Next
This script works fine.
However, I'm not very familiar with VBS-programming (and not with
custom code in Reporting Services either...)
How do I create a report that presents the result from the query?
Any help would be greatly appreciated.
WillyI've been working on a solution, but I'm stuck
In the Report Properties window on the Code tab I've entered the
following code:
Shared Function GetMembersByGroupSQL As String
Dim objGroup As Object
Dim objUser As Object
Dim strQuery As String
objGroup = GetObject("LDAP://CN=MyGroup,OU=MyOU,DC=MyDC")
For Each objUser In objGroup.Members
strQuery = "SELECT Naam = '" & objUser.DisplayName & "'"
Next
Return strQuery
End Function
(I realize I have to alter the For Each construction, in the end I
need strQuery to be something like
SELECT Naam='John' UNION SELECT Naam='Mary' UNION...
For now, only the last row will be returned.)
I've created a new dataset with command type set to 'Text' and entered
the following
= Code.GetMembersByGroupSQL
I've also added a field called 'Naam'.
When I run a report based on this dataset displaying name I get the
following error:
An error has occurred during report processing. (rsProcessingAborted)
Get Online Help
Cannot set the command text for data set 'dsGebruikersPerGroep'.
(rsErrorSettingCommandText) Get Online Help
Error during processing of the CommandText expression of dataset
'dsGebruikersPerGroep'. (rsQueryCommandTextProcessingError) Get Online
Help
There's something wrong with my VB code, because when I replace the
existing code with the following, all works fine:
Shared Function GetMembersByGroupSQL As String
Dim strQuery As String
strQuery = "SELECT Naam = 'John'"
Return strQuery
End Function
It seems like the following line of code is the problem: objGroup =GetObject("LDAP://CN=MyGroup,OU=MyOU,DC=MyDC")
I've tested the code in a vbs-script and it worked fine. Do I need to
add references to assembly's and/or classes to make it work?
Kind regards, Willy
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment