Поделиться через


IPassportManager3::GetCurrentConfig

IPassportManager3::GetCurrentConfig

Returns the contents of a registry key under the registry hive HKLM\SW\Microsoft\Passport. The first parameter specifies the name of the key as seen in the registry.

The most valuable use of this method is to determine a particular request's matching Site ID on the basis of host-name determination, where that Passport Manager installation was established with multi-site support. In previous versions of the Passport Manager application programming interface (API), a site would have to parse the string output of a method such as AuthURL in order to determine the Site ID. For more information, see Configuring Multiple Sites.

Syntax

HRESULT GetCurrentConfig(
    BSTR name, 
    VARIANT *pVal
);

Parameters

  • name
    [in] A BSTR specifying the key name of the configuration value to be retrieved.
  • pVal
    [out, retval] Pointer to a VARIANT containing the value of the requested Microsoft® .NET Passport configuration information.

Return values

Returns one of the following values:

S_OK Success.

Example

The following C++ example retrieves and displays the Site ID, the installation directory, and the language ID.

#include "stdafx.h"
#include <atlbase.h>
#using <mscorlib.dll>
#import "C:/WINNT/system32/MicrosoftPassport/msppmgr.dll" named_guids raw_interfaces_only no_namespace
using namespace System;
// This is the entry point for this application
int _tmain(void)
{
 HRESULT hr;
 IPassportManager3* piMgr;
 hr = CoInitialize(NULL);
 hr = CoCreateInstance(CLSID_Manager, NULL, CLSCTX_INPROC_SERVER, IID_IPassportManager, (void**)&piMgr);
 IUnknown* pII_IPassportManager3;
 piMgr->QueryInterface(IID_IPassportManager3, (void**)&pII_IPassportManager3);

 //Login the user.
 piMgr->LoginUser();

 //Get the SiteID
 BSTR getSiteID = ::SysAllocString(L"SiteID");
 CComVariant pSiteID;
 hr = piMgr->GetCurrentConfig(getSiteID, &pSiteID);
 Console::Write ("Server SiteID = ");
 Console::WriteLine(pSiteID.intVal);

 //Get the Installation Directory
 BSTR getInstallDir = ::SysAllocString(L"InstallDir");
 CComVariant pInstallDir;
 hr = piMgr->GetCurrentConfig(getInstallDir, &pInstallDir);
 Console::Write ("Server InstallDir = ");
 Console::WriteLine(pInstallDir.bstrVal);

 //Get the LanguageID
 BSTR getLangID = ::SysAllocString(L"LanguageID");
 CComVariant pLangID;
 hr = piMgr->GetCurrentConfig(getLangID, &pLangID);
 Console::Write ("Server LanguageID = ");
 Console::WriteLine(pLangID.intVal);

 //cleanup
 hr = piMgr->Release();
 CoUninitialize();
}

The preceding example results in a page that looks similar to the following: 

Server SiteID = 23248
Server InstallDir = C:\Program Files\Microsoft Passport
Server LanguageID = 1033

Remarks

Use this method to determine a particular request's matching Site ID on the basis of host-name determination. Some of the returned values are available from the Passport Manager Administration utility at the server's site.

An attempt to read an attribute will first result in a check for the requested attribute names in the .NET Passport registry that is kept on the server. If found, the named attribute is fetched and a value is returned.

See Also

IPassportManager Interface | Passport Manager Administration Utility