IInternetSecurityManager::MapUrlToZone Method
IInternetSecurityManager::MapUrlToZone Method

Gets the zone index for the specified URL.

Syntax

HRESULT MapUrlToZone(      
    LPCWSTR pwszUrl,     DWORD *pdwZone,     DWORD dwFlags );

Parameters

pwszUrl
[in] A string value that contains the URL. Compare to MapUrlToZoneEx2.
pdwZone
[out] An unsigned long integer variable that receives the zone index.
dwFlags
[in] An unsigned long integer value that specifies MapUrlToZone Flags to control the mapping.

Return Value

Returns E_INVALIDARG if pdwZone is set to NULL, or S_OK otherwise.

Remarks

security note Security Alert  Incorrect implementation of this method can compromise the security of your application. A custom implementation of IInternetSecurityManager::MapUrlToZone should return only zones for URLs that the default application cannot or should not handle. For all other URLs, this method should return INET_E_DEFAULT_ACTION. Attempting to duplicate the default implementation can result in the incorrect mapping of zones and might leave users susceptible to spoofing or elevation of privilege attacks. Review Security Considerations: URL Security Zones API before you contine.

Example

The following example instantiates the default security manager to determine the correct zone for the input URL, szUrl.

const char *rgZoneNames[] = { "Local", "Intranet", "Trusted", "Internet", "Restricted" };

IInternetSecurityManager* pInetSecMgr;
HRESULT hr = CoCreateInstance(CLSID_InternetSecurityManager, NULL, CLSCTX_ALL,
                        IID_IInternetSecurityManager, (void **)&pInetSecMgr);   
if (SUCCEEDED(hr))
{
    DWORD dwZone;
    hr = spInetSecMgr->MapUrlToZone(szUrl, &dwZone, 0);
    if (hr == S_OK)
    {
        if (dwZone < 5)
            printf("ZONE: %s (%d)\n", rgZoneNames[dwZone], dwZone);
        else
            printf("ZONE: Unknown (%d)\n", dwZone);
    }
    else
        printf("ZONE: Error %08x\n", hr);
        
    pInetSecMgr->Release();
} 

See Also

IInternetSecurityManagerEx2::MapUrlToZoneEx2
© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View