Solved

VB Script Method to Capture Authenticated User

Posted on 2009-05-18
2
332 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Resolve DNS query failed errors for Exchange
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

773 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