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

x
?
Solved

User logon name (pre-Windows 2000)

Posted on 2012-04-05
6
Medium Priority
?
457 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
[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
  • 3
  • 3
6 Comments
 
LVL 17

Accepted Solution

by:
Anuroopsundd earned 2000 total points
ID: 37813308
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
ID: 37813365
Okay I got it.  Thanks :)
0
 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37813777
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37813780
Is this what you are looking for?
0
 

Author Comment

by:vhapugsea1
ID: 37813974
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
ID: 37816669
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

610 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