📄 default.aspx
字号:
<%@Page Language="VB" %>
<%@Import Namespace="System.Security.Principal" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<title>Simple Windows Authentication</title>
<style type="text/css">
body {font-family:Tahoma,Arial,sans-serif; font-size:10pt}
input {font-family:Tahoma,Arial,sans-serif; font-size:9pt}
.heading {font-family:Tahoma,Arial,sans-serif; font-size:14pt; font-weight:bold}
.subhead {font-family:Tahoma,Arial,sans-serif; font-size:12pt; font-weight:bold; padding-bottom:5px}
.cite {font-family:Tahoma,Arial,sans-serif; font-size:8pt}
</style></head>
<body bgcolor="#ffffff">
<span class="heading">Simple Windows Authentication</span><hr />
<!--------------------------------------------------------------------------->
<div id="msgHello" runat="server" /><p />
<script language="VB" runat="server">
Sub Page_Load()
'see if the user has been authenticated
If User.Identity.IsAuthenticated Then
'create a reference to a WIndowsIdentity object that
'represents this users Indentity object
Dim objIdentity = CType(User.Identity, WindowsIdentity)
'get the current WindowsIdentity object for this user
'this contains more specific information
Dim objWinIdentity = objIdentity.GetCurrent()
'display the properties
'NOTE: change the group names and the machine name to suit your setup
msgHello.InnerHtml = "Hello <b>" & objWinIdentity.Name & "</b><br />" _
& "The authentication method used was <b>" _
& objWinIdentity.AuthenticationType & "</b><br />" _
& "Is this a System account: <b>" _
& objWinIdentity.IsSystem & "</b><br />" _
& "Is this an Anonymous account: <b>" _
& objWinIdentity.IsAnonymous & "</b><br />" _
& "Is this a Guest account: <b>" _
& objWinIdentity.IsGuest & "</b><br />" _
& "Is this account a member of the 'Administrators' group: <b>" _
& User.IsInRole("BUILTIN\Administrators") & "</b><br />" _
& "Is this account a member of the 'Users' group: <b>" _
& User.IsInRole("BUILTIN\Users") & "</b><br />" _
& "Is this account a member of the '{yourserver}\TestGroup' group: <b>" _
& User.IsInRole("{yourserver}\TestGroup") & "</b><br />" _
& "Is this account a member of the '{yourserver}\NoMembers' group: <b>" _
& User.IsInRole("{yourserver}\NoMembers") & "</b>"
Else
msgHello.InnerHtml = "Hello, you were not authenticated"
End If
End Sub
</script>
<!--------------------------------------------------------------------------->
<hr /><span class="cite">©2001 <a class="cite" href="http://www.wrox.com/">Wrox Press</a> -
<a class="cite" href="http://www.wrox.com/Books/Book_Details.asp?isbn=1861004885">Professional ASP.NET</a> (ISBN: 1-861004-88-5)</span>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -