Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
'==========================================================================
'
' COMMENT: Script for changing Active Directory user passwords
'
'==========================================================================
Dim objuser, newpass, UserLDAP, lngFlag
Const ADS_UF_DONT_EXPIRE_PASSWD = &H10000
Set objuser = GetObject(GetandBind)
newpass = InputBox("enter the new password")
changenextlogin = InputBox("Require User to change password at next logon?" & _
vbCrLf & "Y or N" & vbCrLf & _
"Default is Yes")
objUser.SetPassword newpass
If Ucase(left(changenextlogin,1)) <> "N" Then
objUser.Put "PwdLastSet", 0
End If
objUser.SetInfo
lngFlag = objUser.Get("userAccountControl")
If (lngFlag And ADS_UF_DONT_EXPIRE_PASSWD) <> 0 Then
lngFlag = lngFlag Xor ADS_UF_DONT_EXPIRE_PASSWD
objUser.Put "userAccountControl", lngFlag
objUser.SetInfo
End If
Public Function GetandBind
Dim strname, UserLDAP, UserLDAPString
strname = InputBox("enter the username")
If strname ="" Then
WScript.Quit
End If
UserLDAP = "LDAP://" & SearchDistinguishedName(strname)
On Error Resume Next
Set objUser = GetObject(UserLDAP)
If Err <> 0 Then
MsgBox "Invalid user ID. User not Found."
GetandBind
End If
On Error GoTo 0
MsgBox userLDAP
GetandBind = UserLDAP
End Function
Public Function SearchDistinguishedName(ByVal vSAN)
' Function: SearchDistinguishedName
' Description: Searches the DistinguishedName for a given SamAccountName
' Parameters: ByVal vSAN - The SamAccountName to search
' Returns: The DistinguishedName Name
Dim oRootDSE, oConnection, oCommand, oRecordSet
Set oRootDSE = GetObject("LDAP://rootDSE")
Set oConnection = CreateObject("ADODB.Connection")
oConnection.Open "Provider=ADsDSOObject;"
Set oCommand = CreateObject("ADODB.Command")
oCommand.ActiveConnection = oConnection
oCommand.CommandText = "<LDAP://" & oRootDSE.get("defaultNamingContext") & _
">;(&(objectCategory=User)(samAccountName=" & vSAN & "));distinguishedName;subtree"
Set oRecordSet = oCommand.Execute
On Error Resume Next
SearchDistinguishedName = oRecordSet.Fields("DistinguishedName")
On Error GoTo 0
oConnection.Close
Set oRecordSet = Nothing
Set oCommand = Nothing
Set oConnection = Nothing
Set oRootDSE = Nothing
End Function
'This script records logon information for users with admin rights and records it to a
'database located on a hidden network share on the web server.
On Error Resume Next
Dim adoCn
Dim adoRs
Dim network
Dim user
Dim compname
Dim strSQLInsert
Set network = CreateObject("Wscript.Network")
user = network.username
compname = network.computername
Set adoCn = CreateObject("ADODB.Connection")
adoCn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\server\logs$\log.mdb" 'CHANGE THIS BIT
'Check the connection opened ok
If Err.Number <> 0 Then
Call ErrHandler
End If
strSQLInsert = "INSERT INTO [Log On] ([date], [time], [user], compname) " & _
"VALUES ('" & Date & "', '" & Time & "', '" & user & "', '" & compname & "')"
adoCn.Execute strSQLInsert, , 8
'Check the data was inserted OK
If Err.Number <> 0 Then
Call ErrHandler
End If
adoCn.Close
Set adoCn = Nothing
Set network = Nothing
Sub ErrHandler()
Dim fso, f
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("\\server\logs$\" & LogError & ".txt" , ForAppending, True)
f.WriteLine Date & ", " & Time & ", " & user & ", " & compname & ", " & Chr(34) & Err.Description & Chr(34)
f.Close
Set fso = nothing
Err.Clear
End Sub