using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Security.Principal; namespace Bowin.Common { public class CustomPrincipal : IPrincipal { IIdentity iIdentity; string _UserName; string _logingID; Nullable _OU_ID; string _OU_Name; Nullable _UserID; public CustomPrincipal(IIdentity id, string data) { this.iIdentity = id; //Pengzw Add 2012-11-26 var set = data.Split('|'); this._logingID = set[0]; this._UserName = set[1]; this._OU_ID = string.IsNullOrEmpty(set[2]) ? new Nullable() : new Nullable(Guid.Parse(set[2])); this._OU_Name = set[3]; this._UserID = string.IsNullOrEmpty(set[4]) ? new Nullable() : new Nullable(Guid.Parse(set[4])); this.CurrentRoleName = set[5]; this.CurrentRoleID = string.IsNullOrEmpty(set[6]) ? new Nullable() : new Nullable(Guid.Parse(set[6])); } public Guid? CurrentRoleID { get; private set; } public string CurrentRoleName { get; private set; } public Nullable UserID { get { return _UserID; } } public string UserName { get { return _UserName; } } public string LogingID { get { return _logingID; } } public Nullable OU_ID { get { return _OU_ID; } } public string OU_Name { get { return _OU_Name; } } #region IPrincipal 成员 public IIdentity Identity { get { return iIdentity; } } public bool IsInRole(string UserName) { if (!string.IsNullOrEmpty(UserName)) { return true; } else { return false; } } #endregion } }