1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- 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<Guid> _OU_ID;
- string _OU_Name;
- Nullable<Guid> _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<Guid>() : new Nullable<Guid>(Guid.Parse(set[2]));
- this._OU_Name = set[3];
- this._UserID = string.IsNullOrEmpty(set[4]) ? new Nullable<Guid>() : new Nullable<Guid>(Guid.Parse(set[4]));
- this.CurrentRoleName = set[5];
- this.CurrentRoleID = string.IsNullOrEmpty(set[6]) ? new Nullable<Guid>() : new Nullable<Guid>(Guid.Parse(set[6]));
- }
- public Guid? CurrentRoleID { get; private set; }
- public string CurrentRoleName { get; private set; }
- public Nullable<Guid> UserID
- {
- get { return _UserID; }
- }
- public string UserName
- {
- get { return _UserName; }
- }
- public string LogingID
- {
- get { return _logingID; }
- }
- public Nullable<Guid> 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
- }
- }
|