<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Only load layers from map services user has access to in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/only-load-layers-from-map-services-user-has-access/m-p/365082#M33857</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just wanted to comment that I am seeing the same behaviour that M S describes in re: the "layers-add-result" not firing when one of the services fails to load in the map. In my case, I am using an external service in my app and, if it happens to be down (a situation I have no control over), the "layers-add-result" event is not firing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Jun 2015 17:16:12 GMT</pubDate>
    <dc:creator>JoanneMcGraw</dc:creator>
    <dc:date>2015-06-15T17:16:12Z</dc:date>
    <item>
      <title>Only load layers from map services user has access to</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/only-load-layers-from-map-services-user-has-access/m-p/365079#M33854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a set of map services that I load in my JSAPI app (v3.9), but different users have access to different map services through the app (using windows auth).&amp;nbsp; The app will throw an error (as expected) if the user doesn't have access to a particular map service when I try to add the layers to the map, but when there's an error loading any of the map services, the app won't fire the &lt;/SPAN&gt;&lt;STRONG&gt;layers-add-result&lt;/STRONG&gt;&lt;SPAN&gt; event.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My code essentially boils down to this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;this.map.on('layers-add-result', lang.hitch(this, 'doStuff'));

// Here I add some ArcGISDynamicMapServiceLayer layers here to the 'layers' object.

this.map.addLayers(this.layers);&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I'd like to be able to do is to only add layers to the map that the user has access to.&amp;nbsp; I think this would be similar to doing a check to see if a map service is up before trying to add a layer to the map from it, ie 'check if map service is available - if yes, add layer to map' kind of thing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this possible to do?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 May 2014 19:41:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/only-load-layers-from-map-services-user-has-access/m-p/365079#M33854</guid>
      <dc:creator>MS</dc:creator>
      <dc:date>2014-05-26T19:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: Only load layers from map services user has access to</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/only-load-layers-from-map-services-user-has-access/m-p/365080#M33855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;What I'd like to be able to do is to only add layers to the map that the user has access to.&amp;nbsp; I think this would be similar to doing a check to see if a map service is up before trying to add a layer to the map from it, ie 'check if map service is available - if yes, add layer to map' kind of thing.&lt;BR /&gt;&lt;BR /&gt;Is this possible to do?&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Yes its possible. You can set the permissions on server for different users.&amp;nbsp; or if you want to check for permission in your code only then you can do it by following way-&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-if user is going to add the layer then show(populate) only that layers for which user has access,instead of throwing an error. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-depending upon login type(user login,admin login..)&amp;nbsp; populate the list of layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-For this you will have to apply filter for all layers in your layer list(in which you will have all the layers from server).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-You will filter this depending upon login type &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- use this filtered list to populate the available layers&amp;nbsp; to user. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;"but when there's an error loading any of the map services, the app won't fire the &lt;STRONG&gt;layers-add-result&lt;/STRONG&gt; event."&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; -didnt get this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 11:30:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/only-load-layers-from-map-services-user-has-access/m-p/365080#M33855</guid>
      <dc:creator>GauriDeshmukh</dc:creator>
      <dc:date>2014-05-27T11:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: Only load layers from map services user has access to</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/only-load-layers-from-map-services-user-has-access/m-p/365081#M33856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Yes its possible. You can set the permissions on server for different users.&amp;nbsp; or if you want to check for permission in your code only then you can do it by following way-&lt;BR /&gt;-if user is going to add the layer then show(populate) only that layers for which user has access,instead of throwing an error. &lt;BR /&gt;-depending upon login type(user login,admin login..)&amp;nbsp; populate the list of layers.&lt;BR /&gt;-For this you will have to apply filter for all layers in your layer list(in which you will have all the layers from server).&lt;BR /&gt;-You will filter this depending upon login type &lt;BR /&gt;- use this filtered list to populate the available layers&amp;nbsp; to user. &lt;BR /&gt;&lt;BR /&gt; -didnt get this.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I think I understand what you're saying, as in to have code that decides what layers the user has access to and only request those layers.&amp;nbsp; But I don't want to have to put security code into my app before requesting layers - I want to have the security controlled only at the map service level, ie administered through ArcGIS Server Manager.&amp;nbsp; I would like the app to try to get all the layers, and ignore the ones that the user doesn't have access to.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As far as the event - if I use 'this.map.addLayers(this.layers)' while including a layer that the user doesn't have access to, the addLayers method throws a JavaScript error.&amp;nbsp; Since I have an event to run more code after the layers finish loading, that code will never run when this error occurs.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2014 13:50:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/only-load-layers-from-map-services-user-has-access/m-p/365081#M33856</guid>
      <dc:creator>MS</dc:creator>
      <dc:date>2014-05-27T13:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: Only load layers from map services user has access to</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/only-load-layers-from-map-services-user-has-access/m-p/365082#M33857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just wanted to comment that I am seeing the same behaviour that M S describes in re: the "layers-add-result" not firing when one of the services fails to load in the map. In my case, I am using an external service in my app and, if it happens to be down (a situation I have no control over), the "layers-add-result" event is not firing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 17:16:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/only-load-layers-from-map-services-user-has-access/m-p/365082#M33857</guid>
      <dc:creator>JoanneMcGraw</dc:creator>
      <dc:date>2015-06-15T17:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: Only load layers from map services user has access to</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/only-load-layers-from-map-services-user-has-access/m-p/365083#M33858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I'm wondering if you figured out how to catch this error before adding the layers to the map? I can see the dojo error in my console before the layers are actually added, so there must be some way to catch it. I have the same situation, where I have some secured layers that cause this error to fire, which causes "layers-add-result" not to fire - but only in Internet Explorer, and not consistently - sometimes "layers-add-result" will fire! It always works perfectly in Chrome.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to catch this error prior to adding the secured layers, so I can just skip adding them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Feb 2016 16:17:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/only-load-layers-from-map-services-user-has-access/m-p/365083#M33858</guid>
      <dc:creator>LauraMiles1</dc:creator>
      <dc:date>2016-02-25T16:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: Only load layers from map services user has access to</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/only-load-layers-from-map-services-user-has-access/m-p/365084#M33859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's been a while since I was looking at this myself and from what I remember at the time, I'm not sure that I came up with anything satisfactory. It seems to me that I did figure out a way to trap for this but, because of the lag time in getting the error, couldn't use it the way I wanted...which was to load a different layer on failure. Because the layers in question were acting as basemaps, it meant having to wait too long for the map to populate, etc. etc. I can't really remember the details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Having said all that, you might want to look into lyr.on("error", handler) functionality to see if it will serve your purposes. Again, I can't remember details re: using it but I think that if you create your secured layer object and then attach a handler for an error before you add it to the map, you might be able to work with that somehow.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry if this just confuses the issue, but hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;jtm&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Feb 2016 16:25:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/only-load-layers-from-map-services-user-has-access/m-p/365084#M33859</guid>
      <dc:creator>JoanneMcGraw</dc:creator>
      <dc:date>2016-02-25T16:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Only load layers from map services user has access to</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/only-load-layers-from-map-services-user-has-access/m-p/365085#M33860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for responding - anything is helpful, I will give that a try.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Feb 2016 16:28:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/only-load-layers-from-map-services-user-has-access/m-p/365085#M33860</guid>
      <dc:creator>LauraMiles1</dc:creator>
      <dc:date>2016-02-25T16:28:15Z</dc:date>
    </item>
  </channel>
</rss>

