IPassportManager::DomainFromMemberName
IPassportManager::DomainFromMemberName
Returns a user's domain name as a string.
Syntax
HRESULT DomainFromMemberName( VARIANT memberName, BSTR* pDomainName );
Parameters
- memberName
[in, optional] A VARIANT (should be VT_BSTR) containing a MemberName attribute string.
- pDomainName
[out, retval] A pointer to the BSTR that returns the domain name. If the memberName parameter is left null, the domain name of the user currently signed in to the page will be returned.For information about how to call methods with optional VARIANT inputs, see Passing Empty Variants.
Return values
Returns one of the following values:
S_OK Success. E_FAIL Could not convert MemberName to a string. PP_E_NOT_CONFIGURED Passport Manager object configuration data in the registry is missing or configured incorrectly. PP_E_BAD_DATA_FORMAT MemberName attribute was either stored incorrectly in the Profile cookie or the cookie is corrupt. E_POINTER memberName parameter contained a NULL string. E_INVALIDARG memberName, if provided, did not contain the at sign (@). This performs a quick check for validating a MemberName core profile attribute.
Example
The following C++ example displays the value of the GetDomainFromMemberName method to display the domain of two values, "abc@anycompany.com" and "Default".
#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(); //Check for domain from the provided MemberName CComVariant memberName; BSTR pDomainName; memberName = "abc@anycompany.com"; hr = piMgr->DomainFromMemberName(memberName, &pDomainName); Console::Write("Domain name for anyone@anyplace.com = "); Console::WriteLine(pDomainName); //Check for domain from a default MemberName memberName = "Default"; hr = piMgr->DomainFromMemberName(memberName, &pDomainName); Console::Write("Domain name for 'Default' = "); Console::WriteLine(pDomainName); //cleanup hr = piMgr->Release(); CoUninitialize(); }
Remarks
DomainFromMemberName is a helper function for obtaining the domain name of a currently signed-in user. It is usually called with no input parameter. If an input parameter is provided, the method attempts to match the supplied input parameter to an existing Microsoft .NET Passport domain authority. If no user is signed in and no input parameter is provided, the string "Default", representing the default domain authority as defined in the Component Configuration Document (CCD), will be output.
DomainFromMemberName will return the true domain authority of a user even if the user has an e-mail name as sign-in name. For example, the sign-in name "user@domain.com" (where "domain.com" is not a domain authority) will return the "Default" domain authority. All .NET Passports issued with e-mail name as sign-in name are actually issued by the "passport.com" domain authority. However, do not assume that "passport.com" is always equivalent to "Default" in all configuration aspects. Do not specify the memberName parameter in order to determine the domain authority for a signed-in user. The method determines the signed-in user's identity, but entering a memberName parameter would override this behavior.
See Also