Using Scripts on Web Pages
With only minor modifications, your SMS scripts can be used from Dynamic HTML (DHTML) or ASP Web pages. This allows you to make SMS operations easy to access; they do not have to be restricted to SMS administrators.
Sample C.36 is a DHTML implementation of the part of Sample C.9 that adds the user to a collection. You can create a collection and a package and then advertise the package to the collection. Then users can visit your Web site and select the page that is shown in Sample C.36. In so doing, they add themselves to the collection that you created. SMS then advertises the package to those users, and they receive it like any other SMS advertisement. No intervention is required by an SMS administrator, beyond the initial creation of the collection, package, and advertisement.
Sample C.36 CreateCollection1.html - adds a user to collection
<HTML> <HEAD> <SCRIPT LANGUAGE="VBScript"> <!-- Sub Document_OnClick 'customize the next two lines to suit your site and interest sitecode="MSO" collectionid="SMS00001"Set Service = Locator.ConnectServer (, "root\SMS\site_" & sitecode) 'use the following line instead if the user machine is not the site server (which is usually the case) 'Set Service = Locator.ConnectServer( "servername", "root\SMS\site_" & sitecode, "username", "password") 'determine the current user, as a resource ID Set oWshNetwork=CreateObject("Wscript.Network") username = oWshNetwork.UserName Set Users = Service.ExecQuery("Select * From SMS_R_User WHERE Name LIKE ""%" + username + "%""") For Each User In Users If UCase(User.username) = UCase(username) Then ResID = User.ResourceID Next 'you could add an IF statement here in case the user is not discovered yet Set CollectionRule = Service.Get("SMS_CollectionRuleDirect").SpawnInstance_() CollectionRule.ResourceClassName = "SMS_R_User"CollectionRule.RuleName = "ResourceID=" & ResIDCollectionRule.ResourceID = ResID Set oCollection=Service.Get( "SMS_Collection.CollectionID='" & collectionid & "'" ) oCollection.AddMembershipRule CollectionRule If Err.Number = 0 Then document.all.info.innerText = "You were added to the " & oCollection.Name & " collection. Any advertisements for this collection will soon be available to you."End If end sub --> </SCRIPT> </HEAD> <BODY> <h1>User-Enabled ("Pull") Software Distribution with SMS</h1> <b><SPAN ID="info">Click on this page to add yourself to the SMS00001 collection.</SPAN></b> <OBJECT ID="Locator" CLASSID="CLSID:76A64158-CB41-11D1-8B02-00600806D9B6"> </OBJECT> <OBJECT ID="mysink" CLASSID="CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223"> </OBJECT> </BODY> </HTML>
For More Information
Did you find this information useful? Please send your suggestions and comments about the documentation to smsdocs@microsoft.com.