Asi.Security.appPrincipal.CurrentIdentity.ContactMaster returns empty string

I am trying to pull the currently logged on member's iMIS ID following the Guidlines for Developing iParts from the Innovations Converence (sepcifically duplicating the GetCurrentiMISID method:

public string GetLoggedinIMISID()
{
string _id = "";
try
{
if (Asi.Security.AppPrincipal.CurrentIdentity.IsAuthenticated && Asi.Security.AppPrincipal.CurrentIdentity.ContactMaster != "")
{
_id = Asi.Security.AppPrincipal.CurrentIdentity.ContactMaster;
}
}
catch { }
return _id;
}

I don't get any compile or runtime errors, it just returns blank values.  I am trying to read from a custom table and just display data in a datagrid.  This is 15.0.3 if that matters.  It is an aspx page with code behind.   Any thoughts/help would be greatly appreciated.  I am losing my hair fast enough as it is, thank you.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Use SessionState in ContentManagerNet assembly..

Im presuming this is in eCM .net.

If it is, then we have always used the following:

CContactUser contactUser = Asi.ContentManagerNet.SessionState.User;

The SessionState object usually contains logged in status as well.

Nasser

Actually, no, it is not. 

Actually, no, it is not.  This is 15.0.3 without eCM or WCM, public views.

In 15.0.3 your code won't

In 15.0.3 your code won't work; it will work on the web view, for Casual/Full users, but not for public users. Nasser's code will work fine (even without eCM/WCM), and should carry forward to 15.1+ without any changes as well.

Eric Means
System Architect, ASI

Thanks.  But I need more

Thanks.  But I need more assistance please.  I know, trying to teach an old dog new tricks can be a challenge.  How do I assign that output of that to my variable _id so I can use it to construct the where clause in my sql? 

Simple Sample :)


if (Asi.ContentManagerNet.SessionState.IsLoggedIn)
    _id = Asi.ContentManagerNet.SessionState.User.ContactId;

Eric Means
System Architect, ASI

Thanks!  I was missing the

Thanks!  I was missing the .ContactId!  Guess that helps!