cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

Create different data view based on login

Hello everyone,

 

I have a simple app... it just connect to a SQL table that has 2 columns, the PC name and its local admin password (LAPS basically).

 

We have very few end-user (devs) who must have local admin rights on their machine and I'd like to enable them to see their machine's local admin password from the application (but no other entries).

 

I guess my first question would be:

 

1. Is it possible to create some kind of a manifest in the app, where I could add the person's name with its computer (since I don't have the information, except SCCM, I have to hard code this right?). I thought about having a third column in the data source table with the registered user and having some kind of filtering based on user login... Any better ideas?

 

2. How can I filter the result, based on the login? Meaning when the end-user use the app, he can only see his own machine's local password...

 

 

I guess it's an interesting one for you to scratch your head on!

 

Thanks a lot in advance everyone.

Anthony

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Dual Super User
Dual Super User

Re: Create different data view based on login

Yes, you can add the user email and computer to the table.  I would also add an entry for whether the user is a member of IT or not.  Then this would be the formula.

if(Lookup('[dbo].[LAPS]_1',Email=CurrentUser.Email).IsIt,
    SortByColumns(Search('[dbo].[LAPS]_1', TextSearchBox1.Text,"Name"), "Name", 
         If(SortDescending1, Descending, Ascending),
    Filter('[dbo].[LAPS]_1',Email=CurrentUser.Email))

where Email is the field added to hold the user's email address and IsIt is a boolean field added to hold whether the user is in IT or not.

 

IT users will then see a full searchable list and non-IT users will see their entry.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

7 REPLIES 7
Highlighted
Dual Super User
Dual Super User

Re: Create different data view based on login

  • Add a third column to the table that contains the user's email address
  • Create a variable when the app starts to store the logged in user's email 

 

 

set(currentUser,user().email)​  

 

 

  • Filter the data source using the variable to only show the currentUser's entry

 

 

Filter(SQL,emailcolumn = currentUser)

 

 

​That will do what you are asking, but it isn't really security. If a user can find a way to get to the SQL



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
Helper IV
Helper IV

Re: Create different data view based on login

Hi @Pstork1 

 

Thanks for your answer!

 

I can add a 3rd column yes... and hard code the email address of the associated user to a certain machine.

 

Please keep in mind that all IT employees will be able to see all entries - no filtering needed.

ONLY few end-users (not IT), who need to have local admin access on their machine will be able to only see their own workstation, but not the other ones...

 

So I guess, we need to have an IF statement with the filtering saying that if user = enduserwithadminrights, then onlyshowyourassociatedmachine. ELSE, show all machines.

 

The code you have sent me, where do you put it exactly? On the gallery? 

 

 

Thanks!

Anthony

 

Highlighted
Dual Super User
Dual Super User

Re: Create different data view based on login

Set the variable in the OnStart property of the app and add the filter to the items property of the gallery.  But yes, you'll need to add an IF() to handle the case where the user is in IT.  If the user is in IT then show the datasource unfiltered, but if the user isn't then use the filter statement I provided.

 

My point was that even for non-IT users this isn't really security.  They could make their own app using the SQL connection and show the data without the filter.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
Helper IV
Helper IV

Re: Create different data view based on login

Hi @Pstork1 

 

Thanks! I have set the variable on the OnStart property of my screen.

 

This below, is my code of the Items property of my gallery:

SortByColumns(Search('[dbo].[LAPS]_1', TextSearchBox1.Text,"Name"), "Name", If(SortDescending1, Descending, Ascending))

 

Instead of creating a new table in SQL, could I just simply hard code in here the username and the computer name?

Like: If CurrentUser.Email = john@domain.com, then Filter to only show PC001 

 

I'm still learning the code, I'm kinda new to it.

Would you be able to help me with the formula to use?

 

Thank you so much in advance.

Anthony

Highlighted
Dual Super User
Dual Super User

Re: Create different data view based on login

Yes, you can add the user email and computer to the table.  I would also add an entry for whether the user is a member of IT or not.  Then this would be the formula.

if(Lookup('[dbo].[LAPS]_1',Email=CurrentUser.Email).IsIt,
    SortByColumns(Search('[dbo].[LAPS]_1', TextSearchBox1.Text,"Name"), "Name", 
         If(SortDescending1, Descending, Ascending),
    Filter('[dbo].[LAPS]_1',Email=CurrentUser.Email))

where Email is the field added to hold the user's email address and IsIt is a boolean field added to hold whether the user is in IT or not.

 

IT users will then see a full searchable list and non-IT users will see their entry.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Highlighted
Helper IV
Helper IV

Re: Create different data view based on login

Thanks @Pstork1  !

 

So according to you there is no way of avoiding the creation of a new column?

It is not possible to hard code the username and the PC name into the formula inside the app under a filter/lookup?

 

Thanks!

Anthony

Highlighted
Dual Super User
Dual Super User

Re: Create different data view based on login

If the App is only going to be used by one user then you could hardcode the name into the app, but if you want to have it be dynamic I don't see how you can do it without adding that information to each record in the data source.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (13,070)