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 ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23
Link to this page: //www.vb-net.com/asp2/3/18.htm
<SITEMAP>  <MVC>  <ASP>  <NET>  <DATA>  <KIOSK>  <FLEX>  <SQL>  <NOTES>  <LINUX>  <MONO>  <FREEWARE>  <DOCS>  <ENG>  <CHAT ME>  <ABOUT ME>  < THANKS ME>