keybrdcowboy
IS-IT--Management
Well, I have been reaserching this for a day now, and from what I have been reading, it's not possible to hide the password using just VBscript. (For background purposes, I am prompting the user for a username and password which then connects to AD using those credintials) It works fine right now just have the user type in the info using Input Boxes, but I would like for the password to be starred out, or hidden, so someon sitting behind the user can't see it. I have tried using one dll thing I found ont he internet, but now I get a type mismatch error, and I can't figure out why. Can anyone help, or provide a different solution? Thanks a lot. You guys have come through for me before, so I'm trying again. Here's the code.
' Sets the script up to manipulate files
Set fso = CreateObject("Scripting.FileSystemObject")
' Sets the path to the textfile to read from
Set readfile = fs
penTextFile("c:\documents and settings\mobleyj\desktop\usernametest.txt")
' Reads the contents of the file into an array named arrBadUsernames
iUpperBound = 0
While Not readfile.AtEndOfStream
ReDim Preserve arrBadUsernames(iUpperBound)
arrBadUsernames(UBound(arrBadUsernames)) = readfile.ReadLine
iUpperBound = iUpperBound + 1
Wend
' Closes the connection to the file
readfile.Close
' Sets the domain the script is working in
strDomain = "domain"
set objLogon = CreateObject("PassDlg.LogonDialog")
objLogon.ShowDialog "Enter your administrative username and password:"
objCancelled = objLogon.Canceled
objlogon.AllowBlankUsername = False
objLogon.AllowBlankPassword = False
objCancelled = objLogon.Canceled
strUsername = objLogon.Username
strPassword = objLogon.Password
If objCancelled Then
wscript.quit
End If
wscript.echo strUsername
wscript.echo strPassword
wscript.echo strDomain
' Pops up a message box asking for the username and password to use to connect to active directory
'strUsername = inputbox("Please type in your administrative username:", "AdminUsername")
' If strUsername = "" Then
' wscript.quit
'End If
'strPassword = inputbox("Please type in your administrative password:", "AdminPassword")
' If strPassword = "" Then
' wscript.quit
' End If
' Tells the script to take all the names that were in the text file, and one at a time, set the account
' so that the user has to change their password at next logon
For Each entry in arrBadUsernames
' Makes the connection to Active Directory using the username and password the user specified
Set objIADS = GetObject("WinNT:").OpenDSObject("WinNT://" & strDomain, strUsername, strPassword, ADS_SECURE_AUTHENTICATION)
'The code below actually does the manipulating of the user accounts, then clears all the variables
Set oUser = objIADS.GetObject("user", entry)
oUser.put "PasswordExpired",1
oUser.SetInfo
set oUser = Nothing
set strUsername = Nothing
set strPassword = Nothing
Next
' Sets the script up to manipulate files
Set fso = CreateObject("Scripting.FileSystemObject")
' Sets the path to the textfile to read from
Set readfile = fs
' Reads the contents of the file into an array named arrBadUsernames
iUpperBound = 0
While Not readfile.AtEndOfStream
ReDim Preserve arrBadUsernames(iUpperBound)
arrBadUsernames(UBound(arrBadUsernames)) = readfile.ReadLine
iUpperBound = iUpperBound + 1
Wend
' Closes the connection to the file
readfile.Close
' Sets the domain the script is working in
strDomain = "domain"
set objLogon = CreateObject("PassDlg.LogonDialog")
objLogon.ShowDialog "Enter your administrative username and password:"
objCancelled = objLogon.Canceled
objlogon.AllowBlankUsername = False
objLogon.AllowBlankPassword = False
objCancelled = objLogon.Canceled
strUsername = objLogon.Username
strPassword = objLogon.Password
If objCancelled Then
wscript.quit
End If
wscript.echo strUsername
wscript.echo strPassword
wscript.echo strDomain
' Pops up a message box asking for the username and password to use to connect to active directory
'strUsername = inputbox("Please type in your administrative username:", "AdminUsername")
' If strUsername = "" Then
' wscript.quit
'End If
'strPassword = inputbox("Please type in your administrative password:", "AdminPassword")
' If strPassword = "" Then
' wscript.quit
' End If
' Tells the script to take all the names that were in the text file, and one at a time, set the account
' so that the user has to change their password at next logon
For Each entry in arrBadUsernames
' Makes the connection to Active Directory using the username and password the user specified
Set objIADS = GetObject("WinNT:").OpenDSObject("WinNT://" & strDomain, strUsername, strPassword, ADS_SECURE_AUTHENTICATION)
'The code below actually does the manipulating of the user accounts, then clears all the variables
Set oUser = objIADS.GetObject("user", entry)
oUser.put "PasswordExpired",1
oUser.SetInfo
set oUser = Nothing
set strUsername = Nothing
set strPassword = Nothing
Next