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
Solved

User logon name (pre-Windows 2000)

Posted on 2012-04-05
6
444 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
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

837 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