Share via


PassportIdentity.GetDomainFromMemberName

PassportIdentity.GetDomainFromMemberName

Returns the user's domain name as a string.

Syntax

public string GetDomainFromMemberName( string strMemberName )

Parameters

  • strMemberName
    The name of the user.

Return value

The user's domain name. If strMemberName parameter is left null, the domain name of the user currently signed in to the page will be returned.

Example

The following C# example uses the GetDomainFromMemberName method to display the domain name for the signed-in user. This example uses the GetProfileObject method to obtain the user's name and the GetDomainFromMemberName to get the domain.

<%@ Page Language="C#"%>
<HTML>
<HEAD><TITLE>Mysample - Exercise - CS</TITLE></HEAD>
<Script language="C#" runat="server">
 PassportIdentity oMgr;
 string sMembername;
 string strDomain;

 protected void Page_Load(Object src, EventArgs e) {
   oMgr = (PassportIdentity)User.Identity;
 }
</Script>
<%
if (oMgr.GetIsAuthenticated(3600,false,false)) {
 //You are authenticated, get the requested information
 //strDomain is the domain name to query for an attribute
 sMembername = oMgr.GetProfileObject("Membername").ToString();
 strDomain = oMgr.GetDomainFromMemberName(sMembername);

 Response.Write ("<br>GetDomainFromMemberName of " + sMembername + ":");
 Response.Write ("<br>strDomain = " + strDomain);

 sMembername = null;
 strDomain = oMgr.GetDomainFromMemberName(sMembername);

 Response.Write ("<br><br>GetDomainFromMemberName of a " + sMembername + "(null):");
 Response.Write ("<br>strDomain = " + strDomain);
}
else {
 Response.Write ("You have not been authenticated within the last hour. Please exit.");

 sMembername = null;
 strDomain = oMgr.GetDomainFromMemberName(sMembername) ;

 Response.Write ("<br><br>GetDomainFromMemberName of a " + sMembername + "(null):");
 Response.Write ("<br>strDomain = " + strDomain);
} // End if GetIsAuthenticated
%>
</HEAD>
</HTML>.

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, DomainFromMemberName reverts to a simple function that slices all characters before and including "@."

When no strMemberName is provided:

If no user is signed in, the string "Default", representing the default domain authority as defined in the Component Configuration Document (CCD), is returned.

If a user is signed in, the user's domain name is returned.

In the preceding example, if the user is signed in, the GetDomainFromMemberName (null) returns the domain of the user. If no user is signed in, the GetDomainFromMemberName (null) returns "Default".

See Also

Passport PassportIdentity Object | PassportIdentity.GetProfileObject | Component Configuration Document