Solved

User logon name (pre-Windows 2000)

Posted on 2012-04-05
6
438 Views
Last Modified: 2012-04-06
On line 37, how do I specify that I want the pre-Windows 2000 User logon name?

' Define needed constants
Const ForReading = 1
Const ForWriting = 2
Const TriStateUseDefault = -2

Dim arrNames()
intSize = 0

strDomain = "OU=example"

outputPath = "groups.txt"

strPUG = InputBox("Please enter the logon name.")
If strPUG = "" Then
      MsgBox "Operation has been cancelled." & vbCr & "Script will now exit.",vbOKOnly +vbCritical
      WScript.Quit
End If


      FileExists
      GetGroups
      Finish


Function FileExists
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      If objFSO.FileExists(outputPath) Then
            MsgBox "File " & outputPath & " already exists." & vbCr & "Please delete this file and re-run the script." & vbCr & "Script will now exit.",vbOKOnly +vbCritical
            WScript.Quit
      End If
End Function

Function GetGroups
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      Set objFile = objFSO.OpenTextFile(outputPath, ForWriting, True)

      Set objUser = GetObject("LDAP://CN=" & strPUG & "," & strDomain)
      Set colGroups = objUser.Groups

      For Each objGroup in colGroups
            objFile.WriteLine objGroup.CN
      Next
      objFile.Close
End Function

Function Finish
      MsgBox "Success. Please open the file groups.txt.  Script will now exit.", vbOKOnly +vbInformation
End Function
test.vbs
0
Comment
Question by:vhapugsea1
  • 3
  • 3
6 Comments
 
LVL 17

Accepted Solution

by:
Anuroopsundd earned 500 total points
Comment Utility
for pre login name use ADSystemInfo object in your script..

Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.UserName
Wscript.Echo strUserDN
0
 

Author Comment

by:vhapugsea1
Comment Utility
Okay I got it.  Thanks :)
0
 
LVL 17

Expert Comment

by:Anuroopsundd
Comment Utility
Const ForReading = 1
Const ForWriting = 2
Const TriStateUseDefault = -2
Dim objUser
Dim arrNames()
intSize = 0
outputPath = "c:\groups.txt"
strUserDN = InputBox("Please enter the pre-windows 2000 logon name.")

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(outputPath, ForWriting, True)
Set objSysInfo = CreateObject("ADSystemInfo")
'Set objUser = GetObject("LDAP://" & strUserDN)
Set objUser = GetObject("LDAP://" & objSysInfo.Username)


Set colGroups = objUser.Groups
For Each objGroup in colGroups
     objFile.WriteLine objGroup.CN
Next
objFile.Close
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 17

Expert Comment

by:Anuroopsundd
Comment Utility
Is this what you are looking for?
0
 

Author Comment

by:vhapugsea1
Comment Utility
The problem is that "objSysInfo.Username" returns the information of the person that executes the script.

What I want to do is use the InputBox to type in the pre-Windows 2000 logon name and have it process all of the groups that the user is a member of (into the groups.txt file).
0
 

Author Comment

by:vhapugsea1
Comment Utility
Currently the only way I have to get the list of groups that a user is a member of is with this script below.  As you can see, I have to prompt for the user's Last, First, and Middle intial.  What would be easier is if I could simply prompt for the pre-Windows 2000 logon name because then I would have only 1 input box.

' Define needed constants
Const ForReading = 1
Const ForWriting = 2
Const TriStateUseDefault = -2

Dim arrNames()
intSize = 0

strDomain = "example"

outputPath = "groups.txt"


strLast = InputBox("Please enter the last name.")
strFirst = InputBox("Please enter the first name.")
strMid = InputBox("Please enter middle initial.")

GetGroups
Finish

Function GetGroups
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(outputPath, ForWriting, True)
Set objSysInfo = CreateObject("ADSystemInfo")

Set objUser = GetObject("LDAP://CN=" & strLast & "\, " & strFirst & " " & strMid & "," & strDomain)

Set colGroups = objUser.Groups

For Each objGroup in colGroups
      objFile.WriteLine objGroup.CN
Next
objFile.Close
End Function

Function Finish
      MsgBox "Success. Please open the file groups.txt.  Script will now exit.", vbOKOnly +vbInformation
End Function
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now