/// <summary> /// Gets membership id /// </summary> /// <param name="senderInfo">Sender information</param> /// <returns>Collection of management system execution state keys</returns> public override string GetMembershipId(SenderInfo senderInfo) { if ((senderInfo == null) || (senderInfo.Principal == null) || (senderInfo.Principal.Identity == null)) { throw new ArgumentNullException("senderInfo"); } return RbacSystem.Current.GetMembershipId(new RbacUser.RbacUserInfo(senderInfo.Principal.Identity)); }
/// <summary> /// Authorize a user. /// </summary> /// <param name="senderInfo">Sender information</param> /// <param name="userQuota">User quota value</param> /// <returns>User context in which to execute PowerShell cmdlet</returns> public override WindowsIdentity AuthorizeUser(SenderInfo senderInfo, out UserQuota userQuota) { var maxConcurrentRequests = ConfigurationManager.AppSettings["MaxConcurrentRequests"]; var maxRequestsPerTimeslot = ConfigurationManager.AppSettings["MaxRequestsPerTimeslot"]; var timeslotSize = ConfigurationManager.AppSettings["TimeslotSize"]; userQuota = new UserQuota( maxConcurrentRequests != null ? int.Parse(maxConcurrentRequests, CultureInfo.CurrentUICulture) : DefaultMaxConcurrentRequests, maxRequestsPerTimeslot != null ? int.Parse(maxRequestsPerTimeslot, CultureInfo.CurrentUICulture) : DefaultMaxRequestsPerTimeslot, timeslotSize != null ? int.Parse(timeslotSize, CultureInfo.CurrentUICulture) : DefaultTimeslotSize); return WindowsIdentity.GetCurrent(); }
/// <summary> /// Authorizes a user /// </summary> /// <param name="senderInfo">User information</param> /// <param name="quota">Returns user quota</param> /// <returns>WindowsIdentity, if the user is authorized else throws an exception</returns> public override WindowsIdentity AuthorizeUser(SenderInfo senderInfo, out UserQuota quota) { if ((senderInfo == null) || (senderInfo.Principal == null) || (senderInfo.Principal.Identity == null)) { throw new ArgumentNullException("senderInfo"); } if (senderInfo.Principal.Identity.IsAuthenticated == false) { throw new ArgumentException("User is not authenticated"); } RbacUser.RbacUserInfo userInfo = null; if (senderInfo.Principal.WindowsIdentity != null) { userInfo = new RbacUser.RbacUserInfo(senderInfo.Principal.WindowsIdentity); } else { userInfo = new RbacUser.RbacUserInfo(senderInfo.Principal.Identity); } return RbacSystem.Current.AuthorizeUser(userInfo, out quota); }
public abstract string GetMembershipId(SenderInfo senderInfo);
public abstract WindowsIdentity AuthorizeUser(SenderInfo senderInfo, out UserQuota userQuota);
/// <summary> /// Gets membership id /// </summary> /// <param name="senderInfo">Sender information</param> /// <returns>Always returns same membership id for all users which means all users are in same group</returns> public override string GetMembershipId(SenderInfo senderInfo) { return DefaultManagementSystemStateId; }