Solved

VB Script Method to Capture Authenticated User

Posted on 2009-05-18
2
334 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
ID: 24415429
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
ID: 24415577
That works. Thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article runs through the process of deploying a single EXE application selectively to a group of user.
This article outlines the process to identify and resolve account lockout in an Active Directory environment.
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 to another domain controller. Log onto the new domain controller with a user account t…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

735 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