Share via


IWMSAdminAnonUser::SetUserNamePassword

banner art

Previous Next

IWMSAdminAnonUser::SetUserNamePassword

The SetUserNamePassword method specifies a user name and password for use during the authorization process.

Syntax

  HRESULT SetUserNamePassword(
  LPWSTR  newUserName,
  LPWSTR  newPassword
);

Parameters

newUserName

[in] LPWSTR containing the user name. This cannot be longer than 63 characters.

newPassword

[in] LPWSTR containing the password.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code Number Description
E_FAIL 0x80004005 The original password and user name do not exist.
E_INVALIDARG 0x80070057 The newUserName parameter is NULL, the newPassword parameter is NULL, or the length of the user name exceeds 63 characters.
E_OUTOFMEMORY 0x8007000E The server cannot allocate memory for a new user name.

Remarks

Before this function returns, memory used by the server to store the user credentials is zeroed out so that the user name and password are not saved unencrypted on the computer that is running Windows Media Services.

Example Code

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR and CComVariant.

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

// Declare variables and interfaces.
IWMSServer          *pServer;
IWMSPlugins         *pPlugins;
IWMSPlugin          *pPlugin;
IDispatch           *pDispatch;
IWMSAdminAnonUser   *pAdminAnonUser;

HRESULT         hr;
CComVariant     varIndex;
LPWSTR          strUserName;
LPWSTR          strPassword;

// 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 authentication plug-ins.
hr = pServer->get_Authenticators(&pPlugins);
if (FAILED(hr)) goto EXIT;

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

// Retrieve a pointer to the custom interface
// of the plug-in.
hr = pPlugin->get_CustomInterface(&pDispatch);
if (FAILED(hr)) goto EXIT;

// Query the specific administration interface
// for the plug-in.
hr = pDispatch->QueryInterface(IID_IWMSAdminAnonUser,
                              (void **)&pAdminAnonUser);
if (FAILED(hr)) goto EXIT;

// Set a new user name and password to be associated
// with anonymous server connections.
strUserName = L"NewUserName";
strPassword = L"NewPassword";
hr = pAdminAnonUser->SetUserNamePassword(bstrUserName, bstrPassword);
if (FAILED(hr)) goto EXIT;

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

Requirements

Library: WMSServerTypeLib.dll.

Platform: Windows Server 2003 family, Windows Server 2008 family.

See Also

Previous Next