![]() |
Previous | Next |
When an e-service calls the Publisher.PublishPresentation method, Producer checks the security settings that have been specified on the Security tab of the Options dialog box, which can be reached from the Tools menu. These settings allow a user to indicate the security zones in which an e-service must be hosted in order to publish a presentation to the Internet, to an intranet, or to the local computer. If Producer determines that the settings conflict with the chosen publishing destination and the location of the e-service, an error will be generated.
This error can be generated when an e-service calls either Publisher.PublishPresentation or Publisher.ValidatePublishPresentation. Other kinds of publishing errors can be generated by these two methods as well.
If the publishing destination is on a server that requires login, for example, the e-service must specify values for WebHost.Name and WebHost.Password. This information can be supplied by the user through form fields, if necessary. When the presentation is published, the login information is transmitted to the server in an encrypted form. If the login information is incorrect, an error is generated.
Note Microsoft recommends using the HTTPS protocol to transmit user name and password information across a network or the Internet.
An error is caught using the JScript try/catch syntax, and the Error object is used to isolate the error and display an appropriate message. For more information about error handling, see the Error object in the Object Model Reference.
In the case of security zone restrictions, it is sometimes useful for an e-service to check the security settings itself before an error is generated. This allows an e-service to alert the user in a timely fashion when an invalid publishing destination is chosen. It also allows an e-service to filter a list of possible publishing destinations so that the user is only offered destinations that are compatible with their security settings.
The example below illustrates how an e-service can use Options.EServicePublishLocalRestrictions and Options.EServicePublishRestrictions to determine whether the security settings will allow publishing to the chosen destination.
<HTML>
<HEAD>
<SCRIPT>
// Set up some convenience variables.
var Application = window.external;
var MyWebHost = Application.Project.Properties.PublishWebHost;
var LocalProfile = Application.ProfileManager.HighQualityAudioVideo;
var RemoteProfile = Application.ProfileManager.MediumQualityAudioVideo;
// Set a constant that indicates the location of the e-service.
// 1 = local computer, 2 = intranet, 3 = Internet
ESERVICEZONE = 3;
</SCRIPT>
</HEAD>
<BODY>
Choose a publish destination:
<SELECT id="PublishZone" name="PublishZone">
<OPTION value="local" selected="yes">Local Computer</OPTION>
<OPTION value="remote">Remote Computer</OPTION>
</SELECT>
<INPUT type="button" value="Publish" onClick="publish()">
<SCRIPT language="JScript">
function publish() {
if (PublishZone == "local") {
// Test whether the publishing restrictions are
// too restrictive for the e-service's zone.
if (Application.Options.EServicePublishLocalRestrictions < ESERVICEZONE) {
alert("This e-service is not authorized to publish presentations on the local computer. Check your security settings.");
return;
}
// Let the user choose the location on the local computer.
MyWebHost.PublishDestination = Application.Publisher.ChooseDirectory();
if (MyWebHost.PublishDestination == "") {
return; // The user clicked Cancel.
}
MyWebHost.AddProfile(LocalProfile);
} else { // PublishZone == "remote"
// Test whether the publishing restrictions are
// too restrictive for the e-service's zone.
if (Application.Options.EServicePublishRestrictions < ESERVICEZONE) {
alert("This e-service is not authorized to publish presentations on remote computers. Check your security settings.");
return;
}
MyWebHost.PublishDestination = "http://remote_hosting_service";
MyWebHost.AddProfile(RemoteProfile);
}
try {
Application.Publisher.PublishPresentation();
} catch (e) {
alert("There were errors. Publish failed.");
}
}
</SCRIPT>
</BODY>
</HTML>
Previous | Next |