Share via


Event Authorization Callback Procedures

The WMS Active Script Event Handler plug-in responds to event notices raised by the server by calling the appropriate callback in a script file that you create. To implement authorization callback procedures that are associated with read or write access, you must enable an authentication plug-in. If an authentication plug-in is not enabled, the client is denied access to the requested action and the authorization callback procedure is not called. Instead, only the associated event notification callback procedure, if any, is called.

Your script can implement the following event authorization callback procedures.

Function prototype

Description

OnWMSEAuthorizeConnect (UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a client attempts to connect to the server. If the connection is authorized, the server calls the OnWMSEConnect procedure. This procedure cannot be used for a publishing point.

OnWMSEAuthorizeBeginUserSession (UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a client requests a new session.

OnWMSEAuthorizeDescribe (UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a client requests a description of the content. Because this procedure is associated with read access, an authentication plug-in must be enabled before authorization can occur.

OnWMSEAuthorizeGetParameter(UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a client sends an RTSP GET_PARAMETER command or the HTTP/MMS equivalent. (The MMS protocol is not supported in Windows Server 2008 operating systems.)

OnWMSEAuthorizeInitializePlaylist (UserCtx, PresCtx, CmdCtx)

The server calls this procedure when it creates a playlist object. If this event is not authorized, the client is disconnected from the server.

OnWMSEAuthorizeLogicalURLTransform (UserCtx, PresCtx, CmdCtx)

The server calls this procedure when it maps the URL requested by the client to a publishing point.

OnWMSEAuthorizeOpen (UserCtx, PresCtx, CmdCtx)

The server calls this procedure immediately after a describe event. If this event is not authorized, the client is disconnected from the server. Because this procedure is associated with read access, an authentication plug-in must be enabled before authorization can occur.

OnWMSEAuthorizePhysicalURLTransform (UserCtx, PresCtx, CmdCtx)

The server calls this procedure when it transforms a logical URL such as rtsp://server1/movie1.wmv into a physical URL such as file://c:\wmpub\wmroot\movie1.wmv. If this event is not authorized, the client is disconnected from the server. There is no matching notification callback prototype for this procedure.

OnWMSEAuthorizePlay (UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a client requests that the server stream content to it. In the case of a playlist, this procedure is also called as a result of a playlist switch event. If this event is not authorized, the client is disconnected from the server.

OnWMSEAuthorizeSelectStreams (UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a client selects content. If this event is not authorized, the client is disconnected from the server. Because this procedure is associated with read access, an authentication plug-in must be enabled before authorization can occur.

OnWMSEAuthorizeValidatePushDistribution (UserCtx, PresCtx, CmdCtx)

The server calls this procedure when an encoder or distribution server attempts to push content to the server. If the event is authorized, then the server calls the OnWMSEValidatePushDistribution procedure, if it exists. If this event is not authorized, the client is disconnected from the server. Because this procedure is associated with read access, an authentication plug-in must be enabled before authorization can occur.

Each function uses the parameters identified in the following table.

Parameter

Description

UserCtx

An IWMSNamedValues object that contains user context name-value pairs. This is set by the server.

PresCtx

An IWMSNamedValues object that contains presentation context name-value pairs. This is set by the server.

CmdCtx

An IWMSNamedValues object that contains command context name-value pairs. This is set by the server.

The following Visual Basic Scripting Edition (VBScript) example illustrates how to use the authentication callback procedures. Note that both generic and authorization procedures can be implemented in the same script.

VBScript Example

Dim WMSHeartbeat
' Set the interval to 10 seconds.
WMSHeartbeat = 10000

Dim MyFile

Sub CreateAfile
  Dim fso
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set MyFile = fso.CreateTextFile("c:\wmpub\wmroot\testfile.txt", True)
End Sub

Sub TraceInformation( strTraceText )
    MyFile.WriteLine( strTraceText )
    MyFile.WriteLine
End Sub

Sub PrintContextInformation( tempStr, UserCtx, PresCtx, CmdCtx)
    On Error Resume Next
    tempStr = tempStr & chr(13) & chr(10) & "  User Context:"
    for i = 0 to UserCtx.Count - 1
        tempStr = tempStr & chr(13) & chr(10) & "    " & UserCtx ( i ).Name
        tempStr = tempStr & ": " & UserCtx ( i ).Value
    next
    tempStr = tempStr & chr(13) & chr(10) & "  Presentation Context:"
    for i = 0 to PresCtx.Count - 1
        tempStr = tempStr & chr(13) & chr(10) & "    " & PresCtx ( i ).Name
        tempStr = tempStr & ": " & PresCtx ( i ).Value
    next
    tempStr = tempStr & chr(13) & chr(10) & "  Command Request Context:"
    set Ctx = CmdCtx.Request
    for i = 0 to Ctx.Count - 1
        tempStr = tempStr & chr(13) & chr(10) & "    " & Ctx ( i ).Name
        tempStr = tempStr & ": " & Ctx ( i ).Value
    next
    tempStr = tempStr & chr(13) & chr(10) & "  Command Response Context:"
    set Ctx = CmdCtx.Response
    for i = 0 to Ctx.Count - 1
        tempStr = tempStr & chr(13) & chr(10) & "    " & Ctx ( i ).Name
        tempStr = tempStr & ": " & Ctx ( i ).Value
    next
    set Ctx = Nothing
End Sub

Sub OnWMSPluginInitialize ( ServerCtx )
    CreateAfile
    tempStr = "OnWMSPluginInitialize " & Now
    TraceInformation( tempStr )
End sub

Sub OnWMSPluginHeartbeat ()
    tempStr = "OnWMSPluginHeartbeat " & Now
     TraceInformation( tempStr )
End sub

Sub OnWMSPluginShutdown ()
    tempStr = "OnWMSPluginShutdown " & Now
    TraceInformation( tempStr )
    MyFile.Close
End sub

Function OnWMSEAuthorizeConnect (UserCtx, PresCtx, CmdCtx)
    tempStr = "OnWMSEAuthorizeConnect " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )

    OnWMSEAuthorizeConnect = &H00000000
End Function

Function OnWMSEAuthorizeLogicalURLTransform (UserCtx, PresCtx, CmdCtx)
    tempStr = "OnWMSEAuthorizeLogicalURLTransform " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )

    OnWMSEAuthorizeLogicalURLTransform = &H00000000
End Function

Function OnWMSEAuthorizePhysicalURLTransform (UserCtx, PresCtx, CmdCtx)
    tempStr = "OnWMSEAuthorizePhysicalURLTransform " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )

    OnWMSEAuthorizePhysicalURLTransform = &H00000000
End Function

Function OnWMSEAuthorizeDescribe (UserCtx, PresCtx, CmdCtx)
    tempStr = "OnWMSEAuthorizeDescribe " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )

    OnWMSEAuthorizeDescribe = &H00000000

Function OnWMSEAuthorizeOpen (UserCtx, PresCtx, CmdCtx)
    tempStr = "OnWMSEAuthorizeOpen " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )

    OnWMSEAuthorizeOpen = &H00000000

Function OnWMSEAuthorizeSelectStreams (UserCtx, PresCtx, CmdCtx)
    tempStr = "OnWMSEAuthorizeSelectStreams " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )

    OnWMSEAuthorizeSelectStreams = &H00000000
End Function

Function OnWMSEAuthorizeInitializePlaylist (UserCtx, PresCtx, CmdCtx)
    tempStr = "OnWMSEAuthorizeInitializePlaylist " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )

    OnWMSEAuthorizeInitializePlaylist = &H00000000
End Function

Function OnWMSEAuthorizePlay (UserCtx, PresCtx, CmdCtx)
    tempStr = "OnWMSEAuthorizePlay " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )

    OnWMSEAuthorizePlay = &H00000000

Function OnWMSEAuthorizeGetParameter (UserCtx, PresCtx, CmdCtx)
    tempStr = "OnWMSEAuthorizeGetParameter " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )

    OnWMSEAuthorizeGetParameter = &H00000000
End Function

Function OnWMSEAuthorizeSetParameter (UserCtx, PresCtx, CmdCtx)
    tempStr = "OnWMSEAuthorizeSetParameter" & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )

    OnWMSEAuthorizeSetParameter = &H00000000
End Function

Function OnWMSEAuthorizeValidatePushDistribution (UserCtx, PresCtx, CmdCtx)
    tempStr = "OnWMSEAuthorizeValidatePushDistribution " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )

    OnWMSEAuthorizeValidatePushDistribution = &H00000000
End Function

See Also

Concepts

WMS Active Script Event Handler Plug-in Properties