Results 1 to 4 of 4

Thread: Vbs Script to Retrieve Name of Ads User

  1. #1
    Join Date
    Feb 2009
    Posts
    27

    Vbs Script to Retrieve Name of Ads User

    Hello,

    I am trying to make a vbs script which gives me the first and last name of my AD User that runs the scripts Here is a part of the code:

    Code:
    Select All 
    Set Root = GetObject("LDAP://RootDSE") 
    DomainPath = Root.Get("DefaultNamingContext") 
    Set Domain = GetObject("LDAP://" & DomainPath) 
    Set objUse = GetObject("LDAP://OU=OU-Utilisateurs," & DomainPath) 
    WScript.Echo "First Name: " & objUse.givenName
    But when I run It nothing happens, I have full test without ever seeing the name or surname , In my OU Users OU-I "sub" or "style of Students, Teachers, Admin please Give me Proper Suggestions and Code that you might Have use to Achieve the Following results.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Vbs Script to Retrieve Name of Ads User

    Hello , You Can Checkout the Following

    Code:
    Set objWMISvc = GetObject( "winmgmts:\\.\root\cimv2" )
    Set colItems = objWMISvc.ExecQuery( "Select * from Win32_ComputerSystem", , 48 )
    For Each objItem in colItems
        strUserName = objItem.UserName
        WScript.Echo "User Name: " & strUserName
    Next
    it Might Help You

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Vbs Script to Retrieve Name of Ads User

    Hello , You Can the command "net user", it Will tell you the Same Things .You can use the net user command to create and modify user accounts on omputers. When you use this command without command-line switches, the user accounts for the computer are listed. The user account information is stored in the user accounts database. This command works only on servers.

  4. #4
    Join Date
    Nov 2005
    Posts
    1,323

    Re: Vbs Script to Retrieve Name of Ads User

    Hello , You might want to Check these Code also if it help you


    Code:
    Public Function UserName() As String
        On Error Resume Next
        Dim oSysInfo As New ActiveDs.WinNTSystemInfo
        UserName = oSysInfo.UserName
        Set oSysInfo = Nothing
    End Function

Similar Threads

  1. Script to change User Profile paths
    By gram in forum Windows Server Help
    Replies: 4
    Last Post: 10-05-2010, 11:37 PM
  2. Script that allows me to Switch User
    By The Recruiter in forum Software Development
    Replies: 6
    Last Post: 05-01-2010, 10:39 PM
  3. Selecting a user in a shell script
    By Quattro in forum Operating Systems
    Replies: 5
    Last Post: 25-12-2009, 02:11 PM
  4. Script to Update user attributes in AD
    By Fahad in forum Active Directory
    Replies: 3
    Last Post: 29-05-2009, 02:44 AM
  5. VB script - List all user groups Help
    By Daljeet in forum Software Development
    Replies: 4
    Last Post: 18-12-2008, 07:51 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,994,561.30752 seconds with 16 queries