ok,
on my server....which works my context.User is of type:
BNFL_EnergyUnit.CODE.BLL.energyCUSTOM_PRICIPAL
but on the server it is:
System.Security.Principal.GenericPrincipal
something on the server is causing context.User to be a GenericPrincipal
but on my machine it allows me to convert context.user to my
energyCUSTOM_PRICIPAL
Following is my energyCUSTOM_PRICIPAL then inherits IPrincipal
using System;
using System.Security.Principal;
using BNFL_EnergyUnit.CODE.DAL;
using System.Collections;
namespace BNFL_EnergyUnit.CODE.BLL
{
//************************************************** *******************
//
// CustomPrincipal Class
//
// The CustomPrincipal class implements the IPrincipal interface so it
// can be used in place of the GenericPrincipal object. Requirements
for
// implementing the IPrincipal interface include implementing the
// IIdentity interface and an implementation for IsInRole. The custom
// principal is attached to the current request in Global.asax in the
// Authenticate_Request event handler. The user's role is stored in
the
// custom principal object in the Global_AcquireRequestState event
handler.
//
//************************************************** *******************
public class energyCUSTOM_PRICIPAL : IPrincipal
{
private int _UserID;
private int _GroupID = 0;
// Required to implement the IPrincipal interface.
protected IIdentity _Identity;
/// <summary>
/// creates an new instance of the energy unit custom principle which
is a session based object that stores the currently logged on user's
creds. for the current session.
/// </summary>
public energyCUSTOM_PRICIPAL() {}
/// <summary>
/// creates an new instance of the energy unit custom principle which
is a session based object that stores the currently logged on user's
creds. for the current session.
/// </summary>
public energyCUSTOM_PRICIPAL(IIdentity identity, int userID, int
groupID)
{
_Identity = identity;
_UserID = userID;
_GroupID = groupID;
}
// IIdentity property used to retrieve the Identity object attached to
// this principal.
public IIdentity Identity
{
get { return _Identity; }
set { _Identity = value; }
}
// The user's ID, created when the user was inserted into the database
public int UserID
{
get { return _UserID; }
set { _UserID = value; }
}
/// <summary>
/// the users access level editor / content manager / super admin
/// </summary>
public int GroupID
{
get { return _GroupID; }
set { _GroupID = value; }
}
//************************************************** ******************
*
//
// Checks to see if the current user is a member of AT LEAST ONE of
// the roles in the role string. Returns true if found, otherwise
false.
// role is a comma-delimited list of role IDs.
//
//************************************************** ******************
*
public bool IsInRole(string role)
{
string [] roleArray = role.Split(new char[] {','});
foreach (string r in roleArray)
{
if (_GroupID == int.Parse(r))
return true;
}
return false;
}
public bool checkIfUserCanEditThisPage(int userId, int pageId)
{
dataAccessLayer DBLayer = new dataAccessLayer();
return DBLayer.checkIfUserCanEditThisPage(userId, pageId);
}
public ArrayList getUserStreams(int userId, string stream)
{
dataAccessLayer DBLayer = new dataAccessLayer();
return DBLayer.getUserStreams(userId, stream);
}
public static void updateUsersLastLoginDate(int userId)
{
dataAccessLayer DBLayer = new dataAccessLayer();
DBLayer.updateUsersLastLoginDate(userId);
}
/*public ArrayList getUserPages(int userId)
{
dataAccessLayer DBLayer = new dataAccessLayer();
return DBLayer.getUserPages(userId);
}*/
}
}
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!