Example #1
0
            /// <summary>
            /// The configuration callback reply.
            /// </summary>
            /// <param name="systemAuthenticationConfiguration">The system authenticationConfiguration stored on the
            /// server.</param>
            public void OnReply(ISystemAuthenticationConfiguration systemAuthenticationConfiguration)
            {
                var builder = theSystemAuthenticationControl.ScriptBuilder();

                // For all system users...
                foreach (var principal in systemAuthenticationConfiguration.Principals)
                {
                    var assignedRoles = principal.AssignedRoles;

                    // ...that have the 'SUPERUSER' assigned role...
                    if (!assignedRoles.Contains("SUPERUSER"))
                    {
                        continue;
                    }

                    var newRoles = new HashSet <string>(assignedRoles);

                    newRoles.Remove("SUPERUSER");
                    newRoles.Add("ADMINISTRATOR");

                    // ...and add a command to the script that updates the user's assigned roles, replacing 'SUPERUSER'
                    // with 'ADMINISTRATOR'.
                    builder = builder.AssignRoles(principal.Name, newRoles.ToList());
                }

                var script = builder.Script();

                theSystemAuthenticationControl.UpdateStore(script, theCallback);
            }
            /// <summary>
            /// The configuration callback reply.
            /// </summary>
            /// <param name="systemAuthenticationConfiguration">The system authenticationConfiguration stored on the
            /// server.</param>
            public void OnReply( ISystemAuthenticationConfiguration systemAuthenticationConfiguration )
            {
                var builder = theSystemAuthenticationControl.ScriptBuilder();

                // For all system users...
                foreach ( var principal in systemAuthenticationConfiguration.Principals ) {
                    var assignedRoles = principal.AssignedRoles;

                    // ...that have the 'SUPERUSER' assigned role...
                    if ( !assignedRoles.Contains( "SUPERUSER" ) )
                        continue;

                    var newRoles = new HashSet<string>( assignedRoles );

                    newRoles.Remove( "SUPERUSER" );
                    newRoles.Add( "ADMINISTRATOR" );

                    // ...and add a command to the script that updates the user's assigned roles, replacing 'SUPERUSER'
                    // with 'ADMINISTRATOR'.
                    builder = builder.AssignRoles( principal.Name, newRoles.ToList() );
                }

                var script = builder.Script();

                theSystemAuthenticationControl.UpdateStore( script, theCallback );
            }