Announcement

Collapse
No announcement yet.

Function to show who is authenticated / logged in

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Function to show who is authenticated / logged in

    Hey all,

    I am looking for a function that I can run from command prompt to tell me the user that is authenticated to Active Directory. I am not looking to show who is authenticated to the local machine.

    This is for an application that uses this to verify authentication to AD before allowing them to continue on to the application.

    Does such a function or command exist?

    Any help would be greatly appreciated.

    Thanks in advance.

  • #2
    Re: Function to show who is authenticated / logged in

    I just got a vbscript to do it...

    Code:
    'This vbs function is originally written by
    ' +----------------------------------------------------------------------------+
    ' |                          Jeffrey M. Hunter                                 |
    ' |                      jhunter(#)idevelopment.info                             |
    ' |                         www.idevelopment.info                              |
    ' |----------------------------------------------------------------------------|
    ' |      Copyright (c) 1998-2009 Jeffrey M. Hunter. All rights reserved.       |
    ' |----------------------------------------------------------------------------|
    ' | FILE       : WhoAmI.vbs                                                    |
    ' | CLASS      : Networking                                                    |
    ' | PURPOSE    : Determine currently logged in user.                           |
    ' | PARAMETERS : None                                                          |
    ' | USAGE      : cscript WhoAmI.vbs //NoLogo                                   |
    ' | NOTE       : As with any code, ensure to test this script in a development |
    ' |              environment before attempting to run it in production.        |
    ' +----------------------------------------------------------------------------+
     
    Option Explicit
    
    Function Main
        
        Dim objNetwork
        Dim strCurrentUserName, strCurrentDomainName, strFullUserName
        Dim strComputerName
    
        Set objNetwork = WScript.CreateObject("WScript.Network")
    
        strCurrentUserName = objNetwork.UserName
        strCurrentDomainName = objNetwork.UserDomain
        strComputerName = objNetwork.ComputerName
        
        strFullUserName = strCurrentDomainName & "\" & strCurrentUserName
        
        WScript.Echo strFullUserName
        
    End Function
    
    Main
    WScript.Quit(0)
    Last edited by Rems; 10th December 2009, 17:00. Reason: Wrap script in CODE tag

    Comment


    • #3
      Re: Function to show who is authenticated / logged in

      Hi,

      Nice script, did you write it yourself? There is another very similar in here named WhoamI.vbs: http://www.idevelopment.info/cgi/PRO...ng_scripts.cgi
      The script doesn't imply that the user is authenticated in AD though as you originally requested, unless that wasn't what you meant
      If the user is using the cached in credentials the script would still return the same.
      Caesar's cipher - 3

      ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

      SFX JNRS FC U6 MNGR

      Comment


      • #4
        Re: Function to show who is authenticated / logged in

        The code is exactly like Jeffrey M. Hunter's function.
        Only two lines are modified just a little and the Author's tag was been removed. No link to the source was provided.

        Therefore I have restored the Author's tag.

        Thanks.


        @brembold,
        Give credit to who ever deserves it, and if possible, a link to where you got your information/tools from (review #11 of our forum rules)

        \Rems

        This posting is provided "AS IS" with no warranties, and confers no rights.

        __________________

        ** Remember to give credit where credit's due **
        and leave Reputation Points for meaningful posts

        Comment

        Working...
        X