00001: Imports System.Security.Principal
00002: Partial Class _Default
00003:     Inherits System.Web.UI.Page
00004: 
00005:     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
00006:         Label1.Text = WindowsIdentity.GetCurrent.Name
00007:         '
00008:         Dim context As HttpContext = HttpContext.Current
00009:         Dim iServiceProvider As IServiceProvider = context
00010:         Dim httpWorkerRequestType As Type = GetType(HttpWorkerRequest)
00011:         Dim httpWorkerRequest As HttpWorkerRequest = iServiceProvider.GetService(httpWorkerRequestType)
00012:         Dim ptrUserToken As IntPtr = httpWorkerRequest.GetUserToken
00013:         Dim winIdentity As WindowsIdentity = New WindowsIdentity(ptrUserToken)
00014:         Dim impContext As WindowsImpersonationContext = winIdentity.Impersonate
00015:         Label4.Text = WindowsIdentity.GetCurrent.Name
00016:         '
00017:         impContext.Undo()
00018:         Label6.Text = WindowsIdentity.GetCurrent.Name
00019:     End Sub
00020: End Class


Comments ( )
Link to this page: //www.vb-net.com/asp2/3/18.htm
< THANKS ME>