teepes
asked on
Need help with VBS and HTML
Hello I have a script that when ran as a .vbs file it shows me all locked user accounts. When i try to put it into an html file it wont work.
Am i missing something? You would think if it runs as a .vbs file it would run in an html file.
Am i missing something? You would think if it runs as a .vbs file it would run in an html file.
<html>
<head>
<title>Woot</title>
<script type="text/vbscript">
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT distinguishedName FROM 'LDAP://dc=domain,dc=domain,dc=domain,dc=com' WHERE objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strDN = objRecordset.Fields("distinguishedName").Value
Set objUser = GetObject ("LDAP://" & strDN)
If objuser.isAccountlocked = True Then
document.write objuser.samAccountName
objRecordSet.MoveNext
Else
objrecordset.MoveNext
End If
Set objuser = Nothing
Loop
</script>
</head>
<body>
</body>
</html>
Place your <script> 'between' your </head> & <body>
ASKER
I have tried putting it in everyspot and nothing works.
Are you trying to develop an HTA?
If so, name the file 'filename.hta'
Otherwise, ignore this post.
If so, name the file 'filename.hta'
Otherwise, ignore this post.
<html>
<head>
<title>Woot</title>
<HTA:Application ID="myApp"
ApplicationName="My App"
>
</head>
<script Language="VBScript">
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT distinguishedName FROM 'LDAP://dc=domain,dc=domain,dc=domain,dc=com' WHERE objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strDN = objRecordset.Fields("distinguishedName").Value
Set objUser = GetObject ("LDAP://" & strDN)
If objuser.isAccountlocked = True Then
document.write objuser.samAccountName
objRecordSet.MoveNext
Else
objrecordset.MoveNext
End If
Set objuser = Nothing
Loop
</script>
<body>
</body>
</html>
ASKER
well basically what i'm doing is building a vista gadget. I'm not sure if it will work with .hta.
Oh...haven't tried that myself yet...don't even know where to begin.
However, I would suggest simplifying the code greatly - perhaps just include an msgbox or something to alert you that the script section is even running...
However, I would suggest simplifying the code greatly - perhaps just include an msgbox or something to alert you that the script section is even running...
ASKER
The .hta isnt working with my gadget i need it to be HTML.
ASKER
I did some toying around with the script some more, and noticed that if i do the following code in the else statement it will put put hello world for every account not locked out. Then i tried to put in document.write (objuser.samAccountName) in the else statement and it's blank. Don't know if that will tell you guys anything.
If objuser.isAccountlocked = True Then
document.write objuser.samAccountName
objRecordSet.MoveNext
Else
document.write ("hello world")
objrecordset.MoveNext
End If
Set objuser = Nothing
Loop
testing some things now...stand by...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks sirbounty
I am going to award you the points. I posted another question on how i could do something like what i need if any ideas come to mind.
https://www.experts-exchange.com/questions/24310138/List-AD-Locked-users-using-VBScript-and-HTML.html
I am going to award you the points. I posted another question on how i could do something like what i need if any ideas come to mind.
https://www.experts-exchange.com/questions/24310138/List-AD-Locked-users-using-VBScript-and-HTML.html
ASKER
Thanks, if you can think of a way to accomplish what im trying answer my new post
https://www.experts-exchange.com/questions/24310138/List-AD-Locked-users-using-VBScript-and-HTML.html
https://www.experts-exchange.com/questions/24310138/List-AD-Locked-users-using-VBScript-and-HTML.html
Thanx - already working on a 'workaround' of sorts...I'll post in the other thread...