Exemplo n.º 1
0
        /// <summary>
        /// Assign a role to an existing user.
        /// </summary>
        /// <param name="authenticationToken">Encrypted forms auth token identifying the requesting user.</param>
        /// <param name="uniqueIdentifier">The id of the user to update.</param>
        /// <param name="roleName">The role being assigned to the user.</param>
        /// <returns></returns>
        private static bool AddUserToRole(string authenticationToken, string uniqueIdentifier, string roleName)
        {
            /*
             * If you are unable to reference System.Service make sure that the project is configured to
             * use the full 4.0 framework and not the client profile.
             */
            var proxy = new UserManagementServiceClient();
            var result = proxy.AddUserToRole(authenticationToken, uniqueIdentifier, roleName);

            // Handle exceptions
            if (!result.CallSuccess)
            {
                Console.WriteLine(result.FailureMessage);
                return false;
            }

            // The AddUserToRole method does not return ResultData. Return true if the operation completed successfully.
            return true;
        }