Select to view content in your preferred language

Layer Definition using current user/identity

1350
5
07-29-2013 06:04 PM
TrevorMasters
Occasional Contributor
I am trying to establish a way of partitioning layers based on a user/role in a web viewer.

I currently have a web application (.Net MVC) that has an embedded map. I use the current authenticated user together with layer definition queries to get the "appropriate" data for that user. This allows me to have a single map service with all data in it, yet control visibility/access on a per user basis.

This works fine, but now I have been tasked with getting a generic web viewer (JavaScript) working in the same way. Worst case scenario is creating a web viewer (and maybe map service) for each role but I suspect there is a better way. I have been trying to find examples without any success. Maybe my approach is wrong.

Can someone point me in the right direction?
0 Kudos
5 Replies
ManojrajTeli
Deactivated User
Hello Trevor,

You can absolutely do that .On User log in save the user Identity in session, from JavaScript you can get the user id and using web-service or WCF you can get the layer definition and other information and set the layer definition or you can store layer definition in session but it will degrade the performance of the application.

Thanks
Manojraj
0 Kudos
TrevorMasters
Occasional Contributor
Thank you. It is reassuring to know I am on the right track. My JavaScript skills are not great but it looks like they are about to improve 🙂

What do you mean by "storing the layer definition in session"? Do you just mean the actual query string? I have several layers that have layer definitions defined (basically the same query). The data sets are not huge so this has worked OK for me to date.
0 Kudos
ManojrajTeli
Deactivated User
Hello,

I mean to say is "storing the layer definition in session" is for suppose you have state layer across world and you want to show only
states of USA then in that case if attribute is present to differentiate states of various country then you need to do something like
this "Country = 'USA' " int his case country will be column.Now you can store this string in Session variable of ASP.Net and you can retrieve this session variable in Java-script and set layer definition by 
setDefinitionExpression
property .

Thanks
Manojraj
0 Kudos
TrevorMasters
Occasional Contributor
One problem I have up against is that the definition query is visible in the source. For example (using your example) if I had a user that was only allowed to see the features in "Country=USA", they could change the definition and get to see other data. I have no way of stopping this.

The only way around this that I can think of is to have a layer for each country (in this case).
0 Kudos
ManojrajTeli
Deactivated User
Hello Trevor,

There is always chance of exposing service rest endpoint and query string through java-script.Using separate services will increase maintenance work..

Thanks
Manoj
0 Kudos