Dim MyPrincipal As WindowsPrincipal = CType(Thread.CurrentPrincipal, WindowsPrincipal)
If MyPrincipal.IsInRole("DOMAIN_NAME\ADMIN_USER") Then
Username.Text = User.Identity.Name + " is ADMIN_USER done"
'ログインユーザーがAdminの場合のコード
End If
If MyPrincipal.IsInRole("DOMAIN_NAME\OPERATOR") Then
Username.Text = User.Identity.Name + " is OPERATOR done"
'ログインユーザーがOperatorの場合のコード
End If
ここで、IsInRoleに与えるロール名は、[ドメイン名]\[グループ名]とする
Dim principal As System.Security.Principal.WindowsPrincipal = New System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent())
If (principal.IsInRole("DOMAIN\ADMIN_USER")) Then
Username.Text = User.Identity.Name + " is ADMIN_USER"
End If
If (principal.IsInRole("DOMAIN\POWER_USER")) Then
Username.Text = User.Identity.Name + " is POWER_USER"
End If
If (principal.IsInRole("DOMAIN\Domain Users")) Then
Username.Text = User.Identity.Name + " is Domain Users"
End If
If (principal.IsInRole("DOMAIN\Users")) Then
Username.Text = User.Identity.Name + " is Users"
End If