Google Data Studio filter by email and allow all access - acl

I'm creating a Google Data Studio dashboard with the filter by email option. It's easy to do it when you want to allow the user to see only one option, for example
user region
alice A
bob F
charlie Z
But how can I do to give access to some user to all regions from A to Z? Is there a better way to do it than simply creating 26 rows for every user with this admin access?
I'd like to avoid creating this table:
user region
admin A
admin B
admin C
...
admin Z
and instead do something similar to this
user region
admin *

In bigquery connector, you can write custom query like -
select *
FROM table_name
where
case when #DS_USER_EMAIL IN (select distinct map_field from table_name )
then #DS_USER_EMAIL
else 'all' end = map_field
You will have to create a mapping for 'all' one time. But this works. No need to use feature - filter by email id

Related

Joining 2 tables together and using the where function based on a separate mysql query

I am building a training platform for work. I have created the requirements for a user to be trained based on a role given to them. If that role is aligned to a document it will sit against the user. I have managed to get most of the way but am struglling on the best way to finish the where statement within mysqli.
tbldocfiles is a list of my files. I am looking at docid (could be multiple files associated to the document)
tbltrainingaccess sets the roles (driver, warehouseman, customer services) and shows which role (by id) is associated to the document in docfiles.
tblusertraining is the list of users and what role they have associated to them. (driver, warehouseman, customer services).
I am listing the documents associated to the user so have thought the following is the best way:
Look at the user and how many roles he/she is allocated
Look at the roles returned in point 1 (where function)
Identify and match the documents that have the same roles as the user (Join function)
create the list, then look at the unique values for docid. (distinct value)
Example User Bri has the driver and warehouseman role.
There are 5 documents in the db, 3 of them are associated to the driver role (docid 1,2,3) and 2 of them are associated to the warehouseman role (docid 2,4) the 5th document is associayted to customerservice.
My query should do this:
List all documents associated to the roles, that are associated to the user Bri
1
2
3
2
4
Now select unique values (using docid) from the above list:
1,2,3,4.
So my answer will be a used as a count function at the end using mysql_fetch_rows
SELECT DISTINCT tbldocfiles.docid FROM tbldocfiles LEFT JOIN tbltrainingaccess ON (tbldocfiles.docid = tbltrainingaccess.docid) where groupid='1' or groupid='9'
The above code works. but i've got myself confused.
The where statement needs to be the result of a query similar to :
select * from tblusertrainingrole where userid='1' (1 will be a variable based on page selection)
the result in this would be 1, 9 which are the groupid results.
Basically any help would be appreciated! I am sure it will be simple but have burnt myself out on this for a while and most answers in here helped with joining but not the where statement (that I could find)
Thank you in advance everyone!
You can do a select statement in the where. Since it is an or statement you can use in for the results. Please replace * with the column name for the value you need. Should look like
where groupid in (select * from tblusertrainingrole where userid = '1')

SSRS When uploading report owner name is wrong

I have SQL 2014 professional version 12.0.5000.0 with SSRS runing. eI have created a report in report builder 3.0 which works and runs find.
However when I go to create a subscription and run I get the user a1234 (as a example ) don't exist.
I looked there is no user with that name added to SSRS or in our domain.
my user name is ah1234 (as a example )
I looked in the subscription table and the owner is me ? However, the subscription is showing the owner as a1234?
I checked the report I uploaded it says the owner is a1234.
I'm thinking it might be a active directory issue but not sure.
Has anyone has see this before if so how can I fix the owner name of the subscription?
I don't know how SSRS has corrupted the owner name but here is a trick (written on 2008 R2) to correct owner names (I use this when people leave & their Active Directory user id gets deleted leaving orphaned subs that will not run).
Note that it updates the Microsoft-supplied subscriptions table, you may not wish to do that.
First identify the SSRS owner id for the from-person & also that of the to-person (you may need to get the to-person to create a subscription first):
SELECT distinct [OwnerID], u.username
FROM [<ssrs-database>].[dbo].[Subscriptions] s
join [<ssrs-database>].[dbo].[Users] u on s.ownerid = u.userid
Now make a safe copy of the subscriptions list, e.g.:
SELECT * into temp.subscriptionscpy
FROM [<ssrs-database>].[dbo].[Subscriptions] s
Now make the change, e.g. (this one changes the owner of all relevant subs):
update [<ssrs-database>].[dbo].[Subscriptions]
set ownerid = 'DDD87598-8957-42C8-8DBC-A893E7174CB6'
where ownerid = 'EBF0E483-69E6-4458-B171-BA28FFCCDF3F'
Now check the owner is as you want it.

Flask-Admin/SQLAchemy: Standard idiom to produce a row-filtered user view

Using SQLAlchemy through Flask-Admin/Flask-Security.
I have 2 roles: "admin" and "user"
Normal users own certain parts of the data (certain rows of the tables) and should only access their own data.
What is the standard idiom only allowing users to access their data but not other users' data? I created a special UserView and overrode get_query and get_count_query and included a filter in these methods. Is that the standard way?
I am new to SLQAlchemy, and I am having trouble filtering tables that are "distant" from the User table.
For example: User to Project (many-to-one), Project to X (many-to-many), X to Y (many-to-many), all with backrefs.
How would I filter in the Y view for a non-admin user to filter only those rows that are reachable from the current user (through Project)?
Thanks!

How to create Google Contact using Google API

I am trying to create Google Contact using Google Contacts API.
According to Google doc(as below), I have already implement the create function.
Google Docs Creating contacts
To create a new contact, send an authorized POST request to the user's contacts feed URL with contact data in the body.
The URL is of the form:
https://www.google.com/m8/feeds/contacts/{userEmail}/full
I use this query to create a contact:
www.google.com/m8/feeds/contacts/{userEmail}/full
However, the new contact is created in the group "Other Contact" by default.
How can I directly create in the group "My Contact"?
Do I need to modify the query?
From the doc (https://developers.google.com/google-apps/contacts/v3/?csw=1#authorizing_requests_to_the_api_name_service):
Contact Group Entry
Contacts can be placed into user-defined groups. You can create,
retrieve, update, and delete these groups using the Contacts Data API,
and you can add contacts to a group or remove contacts from a group.
For details, see the following sections.
The Contacts Data API also provides access to four predefined "system
groups" for each user:
My Contacts Friends Family Coworkers System groups appear in a groups
feed just like user-defined groups do. In fact, system groups are
mostly treated just like other groups. The differences are:
Each system group entry contains a subelement.
The id attribute of that subelement indicates which system group the
group is: Contacts, Friends, Family, or Coworkers. Note that the My
Contacts ID value is simply Contacts, without the "My". Also note
that this system group ID value is different from the group ID given
in the group entry's element. You can't add new system groups,
change the name of a system group, add extended properties to a system
group, or delete a system group. * The contact-group entry
representing a system group doesn't contain a rel="edit" link.
def get_group_id(label_name):
feed = gd_client.GetGroups()
for entry in feed.entry:
if entry.title.text.lower() == label_name:
return entry.id.text
contact_entry = gdata.contacts.data.ContactEntry() #contact_entry
group = get_group_id("My Contact") #group id
membership = gdata.contacts.data.GroupMembershipInfo(href=group) #group membership
contact_entry.group_membership_info.append(membership) # adding group membership to contact_entry
Its not true that contacts can only be placed into user-defined groups. I just experimented with Google Contact V3 API and was able to put a contact under system defined group (My contacts):
ContactEntry contact = new ContactEntry();
Name name = new Name();
final String NO_YOMI = null;
name.setFullName(new FullName("Elizabeth Bennet", NO_YOMI));
name.setGivenName(new GivenName("Elizabeth", NO_YOMI));
name.setFamilyName(new FamilyName("Bennet", NO_YOMI));
contact.setName(name);
GroupMembershipInfo groupInfo = new GroupMembershipInfo();
//You can fetch the following link from GroupEntry#getId()
groupInfo.setHref("http://www.google.com/m8/feeds/groups/{EmailId}/base/{groupId}");
groupInfo.setDeleted(false);
contact.getGroupMembershipInfos().add(groupInfo);
ContactEntry createdContact = myService.insert(new URL(
"https://www.google.com/m8/feeds/contacts/{EmailId}/full"), contact);

Auto username suggestion

I want an auto username suggestion if a username is already used ,using mysql procedure
By User Name suggestion, do you mean you want a type-ahead autocomplete on a login form (i.e. once you type a few characters of your user name, the application will show all user names matching the supplied user name), or do you you mean a suggestion box that provides potential alternate user names if new user supplies an existing user name?
If you're looking for the first, I would recommend avoiding this. By providing a server-side autocomplete for user names, you are providing a simple way to access the names of all users in your system and reducing security (as people trying to access your site without permission will only need to determine a password instead of a user name and password).
If it's the second, one common approach is to append numbers at the end of an existing user name to provide a user name that does not exist. I would recommend doing this in a combination of MySQL and whatever server-side language you are using.
First, get all user names that start with the user name that was supplied (and already exists):
SELECT user_name FROM users where user_name LIKE #userName + '%'
Then, in your server side language, do the following (pseudo-code)
let user = username supplied (already exists)
let recordset = recordset from db call (above)
i = 0
alternateCount = 0
alternatesFound = new string[5]
while (alternateCount < 5 And i < 100)
potentialName = user + i
if (recordset does not contain potentialName)
alternatesFound[alternateCount] = potentialName
alternateCount++
end if
end while
What this does is attempts to insert sucessive numbers (1,2,3) etc. to the supplied user name until it finds 5 cases where the user name is unique. It also does a maximum of 100 iterations in case user1 - user99 is taken (you could increase this but a limit isn't a bad idea.