Select to view content in your preferred language

Allowing access based on login credentials

2299
13
06-21-2012 11:52 AM
JaredWhite
Regular Contributor
I'm in the process of implementing API3's new features and have come up to a potential roadblock.
In my SL app I'm trying to activate different features based on access levels. Say User1 only has permission from the server to view Layer1, and User2 has access to both Layer1 and Feature1. How would I write it so if User1 logs in, he can still use the map and see Layer1, where if User2 logs in, both layers and editor load? Sometime is works, sometimes no layer loads. And how would I keep the programming from challenging lower access level users a second time?

        <esri:Map Name="MyMap" >
            <!-- EsriBasemap-->
            <esri:ArcGISDynamicMapServiceLayer 
                    Url="layerurl"/>
            <!-- Low Access Level Layer-->
            <esri:ArcGISDynamicMapServiceLayer Name="Layer1" 
                    Url="LowAccessLevelURL" />
            <!-- Protected Feature Service-->
            <esri:FeatureLayer   Name= "Feature1"   
                    Url="featureurl" Initialized="FeatureLayer_Initialized"/>            
        </esri:Map>
        <esri:EditorWidget x:Name="MyEditorWidget" Map="{Binding ElementName=MyMap}" Visibility="Collapsed" />


        public MainPage()
        {
            InitializeComponent();
            IdentityManager.Current.ChallengeMethod = SignInDialog.DoSignIn;
        }
        private void FeatureLayer_Initialized(object sender, EventArgs e)
        {
            MyEditorWidget.Visibility = Visibility.Visible;
        }
0 Kudos
13 Replies
DominiqueBroux
Esri Frequent Contributor
Did you set an InitializationFailed handler for all your layers?
0 Kudos
JaredWhite
Regular Contributor
Did you set an InitializationFailed handler for all your layers?


Thank you very much Dominique, that worked... why? (if you've got the time to answer)
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Thank you very much Dominique, that worked... why? (if you've got the time to answer)


Because due to the authorization error, the layers the user has no access  fail to initialize and so the application crashes if you don't handle this failure on InitializationFailed event.
0 Kudos
JaredWhite
Regular Contributor
Because due to the authorization error, the layers the user has no access  fail to initialize and so the application crashes if you don't handle this failure on InitializationFailed event.

  Thanks for the explanation and thanks for the help with the code. You've been a huge help as always.
0 Kudos