Share via


WMS Anonymous User Authentication Plug-in Properties

The WMS Anonymous User Authentication plug-in grants all clients connecting to the server the same permissions as the Windows user account specified by the plug-in. For administration information about this plug-in, see Windows Media Services Help.

You can use the following properties on the IWMSAdminAnonUser interface to configure the plug-in.

Property

Description

AnonymousUserName

Retrieves the name of the Windows user account that is used to specify access permissions when an anonymous user connects to a Windows Media server.

IsPasswordSet

Retrieves a Boolean value indicating whether a password has been associated with anonymous user connections.

You can also use the following method.

Method

Description

SetUserNamePassword

Specifies a user name and password for the authorization process.

Using the IWMSAdminAnonUser interface is illustrated by the following examples.

Visual Basic .NET Example

Imports Microsoft.WindowsMediaServices.Interop 
Imports System.Runtime.InteropServices

Private Sub SetAnonPluginProps() 

' Declare variables.
Dim Server As WMSServer
Dim Plugin As IWMSPlugin
Dim AdminAnonUser As IWMSAdminAnonUser
Dim strUserName As String
Dim bPassword As Boolean

Try
    ' Create a new WMSServer object.
    Server = New WMSServer()

    ' Retrieve the IWMSPlugin object for the 
    ' anonymous authentication plug-in.
    Plugin = Server.Authenticators.Item("WMS Anonymous User Authentication")

    ' Retrieve the administrative interface for the 
    ' anonymous authentication plug-in.
    AdminAnonUser = Plugin.CustomInterface()

    ' Retrieve the user name.
    strUserName = AdminAnonUser.AnonymousUserName

    ' Specify a new user name and password.
    bPassword = AdminAnonUser.IsPasswordSet
    If Not bPassword Then
AdminAnonUser.SetUserNamePassword("NewUserName", "NewPassword")
    End If
Catch excCom As COMException
    ' TODO: Handle COM exceptions.
Catch exc As Exception
    ' TODO: Handle exceptions here.
Finally
    ' TODO: Perform clean-up here.
End Try

End Sub  

C# Example

using Microsoft.WindowsMediaServices.Interop
using System.Runtime.InteropServices;

// Declare variables.
WMSServer Server;
IWMSPlugin Plugin;
IWMSAdminAnonUser AdminAnonUser;

try
{
    // Create a new WMSServer object.
    Server = new WMSServerClass();

    // Retrieve the IWMSPlugin object for the 
    // anonymous authentication plug-in.
    Plugin = Server.Authenticators["WMS Anonymous User Authentication"];

    // Retrieve the administrative interface for the 
    // anonymous authentication plug-in.
    AdminAnonUser = (IWMSAdminAnonUser)Plugin.CustomInterface;

    // Retrieve the user name.
    string strUserName = AdminAnonUser.AnonymousUserName;

    // Specify a new user name and password.
    bool bPassword = AdminAnonUser.IsPasswordSet;
    if (!bPassword)
        AdminAnonUser.SetUserNamePassword("NewUserName", "NewPassword");
}
catch (COMException comExc) {
    // TODO: Handle COM exceptions.
}
catch (Exception exc)
{
    // TODO: Handle exceptions here.
}
finally
{
    // TODO: Perform clean-up here.
}

C++ Example

#include <windows.h>
#include <atlbase.h>

// To access system plug-in interfaces, the
// type library must be imported as shown.
#import "WMSServerTypeLib.dll" no_namespace named_guids \
                               raw_interfaces_only

// Declare variables and interface pointers.
IWMSServer*           pServer = NULL;
IWMSPlugins*          pPlugins = NULL;
IWMSPlugin*           pPlugin = NULL;
IDispatch*            pDispatch = NULL;
IWMSAdminAnonUser*    pAdminAnonUser = NULL;
CComBSTR              bstrUserName;
CComBSTR              bstrPassword;
HRESULT               hr = S_OK;
CComVariant           varIndex;

// Initialize the COM library and retrieve a pointer
// to an IWMSServer interface.
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMSServer,
                      NULL,
                      CLSCTX_ALL,
                      IID_IWMSServer,
                      (void **)&pServer);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to an IWMSPlugins interface
// containing the collection of authentication plug-ins.
hr = pServer->get_Authenticators(&pPlugins);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to the IWMSPlugin interface for the
// WMS Anonymous User Authentication plug-in.
varIndex = "WMS Anonymous User Authentication";
hr = pPlugins->get_Item(varIndex, &pPlugin);
if (FAILED(hr)) goto EXIT;

// Retrieve an IDispatch pointer to the 
// administration interface for the plug-in.
hr = pPlugin->get_CustomInterface(&pDispatch);
if (FAILED(hr)) goto EXIT;

// Call QueryInterface() to retrieve a pointer to the
// IWMSAdminAnonUser interface.
hr = pDispatch->QueryInterface(IID_IWMSAdminAnonUser, (void**)&pAdminAnonUser);
if (FAILED(hr)) goto EXIT;

// Retrieve the user name.
hr = pAdminAnonUser->get_AnonymousUserName(&bstrUserName);
if (FAILED(hr)) goto EXIT;

// Set a new user name and password.
bstrUserName = "NewUserName";
bstrPassword = "NewPassword";
hr = pAdminAnonUser->SetUserNamePassword(bstrUserName, bstrPassword);
if (FAILED(hr)) goto EXIT;

EXIT:
    // TODO: Release temporary COM objects and uninitialize COM.

See Also

Reference

IWMSAdminAnonUser Interface

IWMSAdminAnonUser Object (C#)

IWMSAdminAnonUser Object (Visual Basic .NET)

Concepts

Programming System Plug-in Properties