Solved

User logon name (pre-Windows 2000)

Posted on 2012-04-05
6
441 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
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 …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

24 Experts available now in Live!

Get 1:1 Help Now