Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 327
  • Last Modified:

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.
<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>

Open in new window

0
teepes
Asked:
teepes
  • 6
  • 6
1 Solution
 
sirbountyCommented:
Place your <script> 'between' your </head> & <body>
0
 
teepesAuthor Commented:
I have tried putting it in everyspot and nothing works.
0
 
sirbountyCommented:
Are you trying to develop an HTA?
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>

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
teepesAuthor Commented:
well basically what i'm doing is building a vista gadget. I'm not sure if it will work with .hta.
0
 
sirbountyCommented:
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...
0
 
teepesAuthor Commented:
The .hta isnt working with my gadget i need it to be HTML.
0
 
teepesAuthor Commented:
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 

Open in new window

0
 
sirbountyCommented:
testing some things now...stand by...
0
 
sirbountyCommented:
    Set objUser = GetObject ("LDAP://" & strDN)

may be your issue...

"Thats because, at heart, a gadget is nothing more than a Web page, and, for security reasons, Web pages arent able to make use of GetObject. "

ref: http://www.microsoft.com/technet/scriptcenter/topics/vista/gadgets-pt1.mspx

Doesn't look like that can be accomplished...
0
 
teepesAuthor Commented:
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.

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24310138.html 
0
 
teepesAuthor Commented:
Thanks, if you can think of a way to accomplish what im trying answer my new post

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24310138.html 
0
 
sirbountyCommented:
Thanx - already working on a 'workaround' of sorts...I'll post in the other thread...
0

Featured Post

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.

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now