?
Solved

VB Script Method to Capture Authenticated User

Posted on 2009-05-18
2
Medium Priority
?
341 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 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

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

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

A bad practice commonly found during an account life cycle is to set its password to an initial, insecure password. The Password Reset Tool was developed to make the password reset process easier and more secure.
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
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 …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

807 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