Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB Script Method to Capture Authenticated User

Posted on 2009-05-18
2
Medium Priority
?
339 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
Hubasan earned 2000 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
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 …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

636 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