Ad Hoc reporting with SSRS and shared customer database - reporting-services

I have a database with many customers inside of it. Each row of the table has a customer ID that denotes which customer the data belongs to.
Is it possible to let the end user use Ad-Hoc reporting to build reports, but only let them see data associated to their customer id?

In a report you can use the Built-in field UserID to return the current user's domain name e.g. MYDOMAIN\Username.
If you can create a table mapping customer Ids to domain names and join this to your main data table then you can add a where clause into your dataset query such as
WHERE MappingTable.DomainUsername = #CurrentUser
In the report, create a hidden parameter called CurrentUser and set the value to Globals!UserID.Value
You need to be using Windows authentication in the report data source, where the report users credentials are being passed through to the data source, for this solution to work.
EDIT: I see I misread your original question, which was actually asking if it's possible to allow users to create ad hoc reports while restricting their view of the data. This scenario precludes any solution that is implemented in the reports themselves, since the users will be designing their own reports. Instead, you will probably need to implement some form of security layer in source database, for example using Views. You can use a similar approach to above if your users are using domain logins. For example your view could contain a reference to SUSER_NAME() to limit that data for that particular user.

Related

Can a report be built in Access where users select the fields they want then create said report?

I have an Access database which I have restricted for end users as I do not want them interfering with tables, queries and the like.
Is it possible to develop a tool so that users can select the fields they want to include in a report and then produce said report themselves?
Effectively, I mostly want to replicate the Query Builder function in Access because users do not have access to this due to the (necessary) system restrictions that I have put in place.
Ideally, this is how it will work. End users will:
Open Report function and are presented with a list of tables
Choose required fields.
Add criteria.
Run report.
Can this be / has something like this been done? Does anyone have any examples of such a feature?

MS Access - record level security

I have an MS Access database where all the users will be in the same group, except a few. I don't need to restrict certain objects from users. Instead, I need to give the current user write capabilities to his record and its related records only and read-only capabilities to all other records. Is this possible?
Unfortunately, be it Access, SQL server or Oracle, the restriction of rows to a single user is not built in. This means you have to build some type of interface in which you grab/use the users Logged on ID (their network pc id, or say prompt for a user + password). Then you when a form loads you have to restrict the records to that one given user. There are many ways to do this and they are all standard approaches to filtering or restricting data. However "YOU" have to build and write such code into the forms. You could perhaps base the form on a query with a expression (VBA or macro TempVars) that limits the records returned to the given user.
So you have to “cook” and “code” this ability for most any database. You thus also need to code to “save” the user name who created the record. This coding requirement as noted is required for most systems when looking to restrict data to single rows and such features are not generally built into the database system. You also likely need to restrict and prevent users from opening the database and seeing the table view.

AD, SSRS, and Parameter dropdowns

We have 46 buildings in our company and we want to write reports that allow all buildings to see their data. We have 46 AD groups we've created for another application. What I'd like to do is to populate a dropdown parameter full of the building names, but only show them based on your access in AD.
example:
Administrator1 has access to Building1. He is in group1.
Administrator1 has access to Building2. He is in group2.
Regional1 has access to buildings 1-5. She is in group1, group2, group3, group4, and group5
Exec1 has access to all buildings. She is in all groups.
Exec1 would see all buildings, Admins only their buildings and Regional the group of buildings. Can I populate a parameter dropdown with only the values these people have based on a lookup when they hit the report?
I've used a couple of methods to solve similar problems:
First create an internal parameter for the report which will contain the user's id. "=User!UserID"
Next you need to get the permissions joined in. This is easiest if you have the user to group/permission mapping somewhere in SQL. Then this is just a SQL join.
Otherwise, you can set up a Active Directory "Linked Server" which can query AD for group members. This can take some patience and troubleshooting time. Once set up, you can join to the membership of each group.
If I were building what you describe, I would code an AD to SQL data export to run at regular intervals (a .NET .exe), keeping a SQL table up to date with permissions. This would be easier to set up and more robust than the SQL-> AD Linked Server.
I can find references for the linked server approach if that would be helpful...
If you get the memberOf attribute in AD and loop on the result with a mathching regular expression, I think that you can build your combo.

MS Access Report showing the id of the combobox and not the bound name column

The company I work for have an access database that is linked to a sql server table. The database is on a shared network location so it is used by lots of people in the company (with the annoying problem that only one person can use it at a time).
There are several forms that are used as a front end for the data and on one particular form there are combo boxes that are linked to other tables.
When a report is generated on the form the ID of the combobox is on the form (a GUID) and not the bound item of the combobox.
How can I get the bound items to appear on the form itself? The solution needs to be easy to do or something i can produce that can be regenerated as it's used by non technical people.
In order to make the database usable by many, simply give each user a copy of the front-end.
Forms should almost never be used for reports, the best thing to do is to build a query (the query design window will help) that references each of the relevant tables, for example, if the combobox contained a reference to person type and you might build a query like this for your report:
SELECT a.ID, a.SName, a.MainAddress, c.PersonType
FROM Addresses a
INNER JOIN PersonTypes c ''Or LEFT JOIN if data is missing
ON a.PersonTypeKey = c.PersonTypeKey
If this is not possible, perhaps you could explain in more detail exactly how the report is generated from the form.

How to pass parameters to report model in Reporting Services

I'm developing report in RS that show top N customers based on some criteria. It also allows to select number of customers and period of time.
Is it possible to do it by using report model? Thing that it seems to be difficult is how to pass parameters determined by user.
Another thing that in my oppinion is very disappointing is that i cannot use SQL query as dataset query, because it uses odd and elaborate XML. Although report model items seem to map its fields to query or table fields.
I m concerning using report models because i need to provide uniform data model (the same tables and fields) for more or less different database schemas.
It would be very nice if somebody would explain what can be done with report models and what can not.
Maybe what you're looking for is to use the result of a Stored Procedure as the data source for your report. You would need to define parameters at a Dataset level to pass to the SP
You can create report model based paramaterized filters through the query designer by adding a filter, drag the field you want to filter on into the filter area, then right click on it and select "Prompt". This will automatically create a report parameter which you can then edit via the parameter properties dialog to set the data type, allow multiple values, etc.