0

ページの読み込み時に呼び出す非常に単純なメソッドがあります。次のようになります。

  Protected Sub identify()

    If User.Identity.IsAuthenticated Then

    Else
        Response.Redirect("login.aspx")
    End If
End Sub

私がやりたいのは、ユーザーが属しているロールグループに応じてリダイレクトをスローすることです。したがって、認証されているが「Admins」ユーザーグループの一部ではない場合は、別のページにリダイレクトします。

  Protected Sub identify()

    If User.Identity.IsAuthenticated Then
       If user.Identiy.IsInRoleGroup("Admin")
         Response.Redirect("AdministratorDefault.aspx")
       End If
    Else
        Response.Redirect("login.aspx")
    End If
End Sub

このようなことは可能ですか?答えが見つかりません。

4

1 に答える 1

0

If (User.IsInRole("Administrator")) ... End If

http://msdn.microsoft.com/en-us/library/system.security.principal.windowsprincipal.isinrole.aspx

于 2012-11-01T19:21:38.227 に答える