pass a parameter to LDAP query in SSRS

Is it possible to use a parameter in a ldap query using the ADsDSOObject provider?  I keep getting an error "The ICommandWithParameters interface is not supported by the "ADSDSOObject" provider".  Command parameters are unsupported with the current provider.

I don't have a linked server on my DB server to Active Directory so I'm just querying in the SSRS report design.  Here is my query for my dataset.  If I hard code an example it works.  Just doesn't work when I pass a parameter.  I've tried making it an expression (= sign), Tried several syntax's, Tried everything I can think of.  Is this possible? or do I just need to push for a linked server?

="SELECT        sAMAccountName, displayName, distinguishedName " +
"FROM            'LDAP://DC=xxxx,DC=xx,DC=xx,DC=xx,DC=xx,DC=xx' " +
"WHERE        objectCategory = 'Person' " + 
             "AND objectClass = 'user' " +
             "AND memberOf = '" + @GlobalGroup + "'"

August 20th, 2015 10:03am

Hi nd 2000,

Please check this

http://www.codeproject.com/Articles/67526/Use-SQL-to-view-Active-Directory-Data

Then using a text based query to return the fields in SSRS as per here:

http://www.bidn.com/blogs/Daniel/ssas/1908/ssrs-dataset-fields-disappear-when-using-a-stored-procedure-with-dynamic-sql-%E2%80%93-how-to-get-them-back-and-save-your-report

See the comments at the end of the last article to avoid the cutting and pasting.

Free Windows Admin Tool Kit Click here and download it now
August 20th, 2015 10:26am

That solution you show is using a linked server.  I need to know if it's possible to do this through an ldap query in the dataset itself and pass it a parameter, without using a linked server.
August 20th, 2015 11:01am

Hi, 

According to your description, when creating a expression as a dataset query, you get an error, right? 

In Reporting Services, if you want to pass a parameter value in a expression, you can use Parameters!reportparameter.value to get the parameter value. In your scenario, since you use expression as your dataset query, so you cannot use @GlobalGroup this method to get the parameter value. For your requirement, please refer to the following expression: 

="SELECT sAMAccountName, displayName, distinguishedName " +
"FROM 'LDAP://DC=xxxx,DC=xx,DC=xx,DC=xx,DC=xx,DC=xx' " +
"WHERE objectCategory = 'Person' " + 
       "AND objectClass = 'user' " +
       "AND memberOf = '" + Parameters!GlobalGroup.value + "'"

If you have any other question, please feel free to ask.

Regards, 
Shrek Li


Free Windows Admin Tool Kit Click here and download it now
August 21st, 2015 1:57am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics