Solved

User logon name (pre-Windows 2000)

Posted on 2012-04-05
6
447 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 500 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

691 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