Classe Sys.Services.RoleService
Fornece uma classe de proxy do cliente para o serviço de função ASP.NET.
Namespace: Sys.Services
Herda: Sys.Net.WebServiceProxy
Membros
Nome |
Descrição |
---|---|
Especifica o caminho para o serviço de função padrão. |
|
Inicializa uma nova instância da classe RoleService. |
|
Carrega as funções do usuário autenticado no momento. |
|
Obtém ou define o nome da função de retorno de chamada padrão falhou. |
|
Sys.Services RoleService defaultLoadCompletedCallback propriedade |
Obtém ou define o nome da função de retorno de chamada de carregamento concluído padrão. |
Sys.Services RoleService defaultSucceededCallback propriedade |
Obtém ou define a função de retorno de chamada padrão bem-sucedida para o serviço. |
Obtém ou define o contexto de usuário padrão para o serviço. |
|
Verifica se o usuário autenticado no momento está na função especificada. |
|
Obtém ou define o caminho do serviço de função. |
|
Obtém funções para o usuário autenticado no momento. |
|
Obtém ou define o valor do time limite do serviço de função. |
Comentários
The RoleService classe fornece acesso de script para informações de funções do usuário autenticado no momento. A classe chama métodos do serviço de função usando a mesma infra-estrutura é usado para chamar outros métodos do serviço Web. O Web serviço de função é implementado sistema autônomo uma classe que tem apenas uma instância (singleton). Está sempre disponível para seu aplicativo através de RoleService classe de proxy e você não é necessário que instanciar a ele.
Exemplo
Descrição
O exemplo a seguir mostra como usar o RoleService classe para obter as funções do usuário autenticado no momento. Para obter mais informações, consulte Usando Funções de Informações com AJAX do ASP.NET.
Código
var roleProxy;
var roles;
// This function creates the role proxy and
// sets its default callback functions.
function pageLoad()
{
// Create role service proxy.
roleProxy = Sys.Services.RoleService;
// Set the default failed callback function.
DefaultFailedCallBack();
// Set the default load completed callback function.
DefaultLoadCompletedCallBack()
}
// This function sets and gets the role service
// default failed callback function.
function DefaultFailedCallBack()
{
// Set default failed callback function.
roleProxy.set_defaultFailedCallback(FailedCallback);
// Get the default callback function.
var failedCallBack =
roleProxy.get_defaultFailedCallback();
alert(failedCallBack);
}
// This function sets and gets the role service
// default load completed callback function.
function DefaultLoadCompletedCallBack()
{
// Set the default callback function.
roleProxy.set_defaultLoadCompletedCallback(LoadCompletedCallback);
// Get the default callback function.
var loadCompletedCallBack =
roleProxy.get_defaultLoadCompletedCallback();
alert(loadCompletedCallBack);
}
// This function checks if the currently
// authenticated user belongs to the
// passed role.
function UserIsInRole(role)
{
DisplayInformation("");
var isUserInRole = roleProxy.isUserInRole(role);
DisplayInformation("The user is in the " + role +
" role: " + isUserInRole);
}
// This function gets the role service path.
function GetRoleServicePath()
{
// Get the role service path.
var roleServicePath =
Sys.Services.RoleService.get_path();
if (roleServicePath == "")
{
DisplayInformation(
"The role service path is the default value.");
}
}
// This function gets the roles of the
// currently authenticated user.
function ReadUserRoles()
{
// Clear the feedback output.
DisplayInformation("");
// You must load the user's roles
// first before you can use them.
roleProxy.load();
// Read the user's roles.
roles = roleProxy.get_roles();
}
// This function gets the role service timeout.
function GetRoleServiceTimeout()
{
// Get the role service path.
var roleServiceTimeout =
Sys.Services.RoleService.get_timeout();
DisplayInformation(
"Role service timeout: " + roleServiceTimeout);
}
// This is the callback function
// called if the role service load function
// completed.
function LoadCompletedCallback(roles)
{
// Read the user's roles loaded
// before.
roles.sort();
for(var i = 0; i < roles.length; i++)
{
var roleInfo = "Role: " + roles[i];
DisplayInformation(roleInfo);
}
}
// This is the callback function
// called if the role service fails.
function FailedCallback(error)
{
DisplayInformation("Error: " + error.get_message());
}
// This function displays user's
// feedback information.
function DisplayInformation(text)
{
document.getElementById('placeHolder').innerHTML =
"<br/>"+ text;
}
if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();
Consulte também
Conceitos
Classe Sys.Services.AuthenticationService