Solved

VB Script Method to Capture Authenticated User

Posted on 2009-05-18
2
331 Views
Last Modified: 2012-05-07
I have a VB.Net subroutine that I run on load to capture the user ID of the authenticated user. I use the variable, for example, to notify the user via email of the results. How would I do this in vbscript. Below is the code.

Thanks!
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        lblResults.Visible = False

        imgCheckMark.Visible = False

        imgRedX.Visible = False

        strDate = Now

        strUser = (Request.ServerVariables("AUTH_USER"))
 

        If InStr(strUser, "Domain\") Then

            strUser = Replace(strUser, "Domain\", "")

        End If
 

        If InStr(strUser, "Domain\") Then

            strUser = Replace(strUser, "Domain\", "")

        End If

        Label28.Text = strUser

    End Sub

Open in new window

0
Comment
Question by:JB4375
2 Comments
 
LVL 7

Accepted Solution

by:
Hubasan earned 500 total points
Comment Utility
if you are talking about currently logged on user then you can use the script below:
To get just the userID without a domain, use this instead of the last line:

MsgBox "Current User: " & sCurrentUser
Set oNet = CreateObject("WScript.Network")
 

sDomain = oNet.UserDomain

sCurrentUser = oNet.UserName
 

MsgBox "Current User: "& sDomain & "\" & sCurrentUser

Open in new window

0
 
LVL 1

Author Comment

by:JB4375
Comment Utility
That works. Thanks!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Installing a printer using group policy preferences is not that hard let’s take a look at it. First lets open up your group policy console and edit the policy you want to add it to. I recommend creating a new policy for each printer makes it a l…
[b]Ok so now I will show you how to add a user name to the description at login. [/b] First connect to your DC (Domain Controller / Active Directory Server) SET PERMISSIONS FOR SCRIPT TO UPDATE COMPUTER DESCRIPTION TO USERNAME 1. Open Active …
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now