/// <summary> /// Tests whether the current user has access to a particular Partner. /// </summary> /// <remarks>This Method throws an <see cref="ESecurityPartnerAccessDeniedException" /> /// if access to the Partner is not granted, thereby ensuring that a denied access /// doesn't go unnoticed.</remarks> /// <param name="APartnerRow">Partner for which access should be checked for.</param> /// <param name="AIsFoundation">Set to true if Partner is a Foundation.</param> /// <param name="AFoundationRow">Foundation Row needs to be passed in /// if Partner is a Foundation.</param> /// <returns>void</returns> /// <exception cref="ESecurityPartnerAccessDeniedException">Thrown if access is not granted.</exception> public static void CanAccessPartnerExc(PPartnerRow APartnerRow, bool AIsFoundation, PFoundationRow AFoundationRow) { TPartnerAccessLevelEnum AccessLevel; AccessLevel = CanAccessPartner(APartnerRow, AIsFoundation, AFoundationRow); AccessLevelExceptionEvaluatorAndThrower(APartnerRow, AccessLevel); }
/// <summary> /// Tests whether the current user has access to a particular Partner. /// </summary> /// <remarks> /// <para>Corresponds to Progress 4GL Method 'CanAccessPartner' in /// common/sp_partn.p</para> /// <para>A server-side implementation of this Method exists that has only the /// <paramref name="APartnerRow" />parameter as an Argument. It /// looks up the Foundation Row on its own if this is needed.</para> /// </remarks> /// <param name="APartnerRow">Partner for which access should be checked for.</param> /// <param name="AIsFoundation">Set to true if Partner is a Foundation.</param> /// <param name="AFoundationRow">Foundation Row needs to be passed in /// if Partner is a Foundation.</param> /// <returns><see cref="TPartnerAccessLevelEnum.palGranted" /> if access /// to the Partner is granted, otherwise a different /// <see cref="TPartnerAccessLevelEnum" /> value.</returns> public static TPartnerAccessLevelEnum CanAccessPartner(PPartnerRow APartnerRow, bool AIsFoundation, PFoundationRow AFoundationRow) { TPetraPrincipal userinfo = UserInfo.GetUserInfo(); if ((APartnerRow.Restricted == PARTNER_RESTRICTED_TO_USER) && !((APartnerRow.UserId == userinfo.UserID) || userinfo.IsInModule("SYSMAN"))) { TLogging.LogAtLevel(6, "CanAccessPartner: Access DENIED - Partner " + APartnerRow.PartnerKey.ToString() + " is restriced to User " + APartnerRow.UserId + "!"); return(TPartnerAccessLevelEnum.palRestrictedToUser); } else if ((APartnerRow.Restricted == PARTNER_RESTRICTED_TO_GROUP) && !((userinfo.IsInGroup(APartnerRow.GroupId)) || userinfo.IsInModule("SYSMAN"))) { TLogging.LogAtLevel(6, "CanAccessPartner: Access DENIED - Partner " + APartnerRow.PartnerKey.ToString() + " is restriced to Group " + APartnerRow.GroupId + "!"); return(TPartnerAccessLevelEnum.palRestrictedToGroup); } if (APartnerRow.PartnerClass == SharedTypes.PartnerClassEnumToString(TPartnerClass.ORGANISATION)) { if (AIsFoundation) { if (AFoundationRow != null) { if (!CheckFoundationSecurity(AFoundationRow)) { TLogging.LogAtLevel(6, "CanAccessPartner: Access DENIED - Partner " + APartnerRow.PartnerKey.ToString() + " is restriced by Foundation Ownership!"); return(TPartnerAccessLevelEnum.palRestrictedByFoundationOwnership); } } else { throw new System.ArgumentException("AFoundationRow must not be null if AIsFoundation is true"); } } } TLogging.LogAtLevel(6, "CanAccessPartner: Access to Partner " + APartnerRow.PartnerKey.ToString() + " is GRANTED!"); return(TPartnerAccessLevelEnum.palGranted); }
/// <summary> /// Tests whether the current user has access to a particular Partner. /// </summary> /// <remarks> /// <para>Corresponds to Progress 4GL Method 'CanAccessPartner' in /// common/sp_partn.p</para> /// <para>A server-side implementation of this Method exists that has only the /// <paramref name="APartnerRow" />parameter as an Argument. It /// looks up the Foundation Row on its own if this is needed.</para> /// </remarks> /// <param name="APartnerRow">Partner for which access should be checked for.</param> /// <param name="AIsFoundation">Set to true if Partner is a Foundation.</param> /// <param name="AFoundationRow">Foundation Row needs to be passed in /// if Partner is a Foundation.</param> /// <returns><see cref="TPartnerAccessLevelEnum.palGranted" /> if access /// to the Partner is granted, otherwise a different /// <see cref="TPartnerAccessLevelEnum" /> value.</returns> public static TPartnerAccessLevelEnum CanAccessPartner(PPartnerRow APartnerRow, bool AIsFoundation, PFoundationRow AFoundationRow) { if ((APartnerRow.Restricted == PARTNER_RESTRICTED_TO_USER) && !((APartnerRow.UserId == UserInfo.GUserInfo.UserID) || UserInfo.GUserInfo.IsInModule("SYSMAN"))) { TLogging.LogAtLevel(6, "CanAccessPartner: Access DENIED - Partner " + APartnerRow.PartnerKey.ToString() + " is restriced to User " + APartnerRow.UserId + "!"); return TPartnerAccessLevelEnum.palRestrictedToUser; } else if ((APartnerRow.Restricted == PARTNER_RESTRICTED_TO_GROUP) && !((UserInfo.GUserInfo.IsInGroup(APartnerRow.GroupId)) || UserInfo.GUserInfo.IsInModule("SYSMAN"))) { TLogging.LogAtLevel(6, "CanAccessPartner: Access DENIED - Partner " + APartnerRow.PartnerKey.ToString() + " is restriced to Group " + APartnerRow.GroupId + "!"); return TPartnerAccessLevelEnum.palRestrictedToGroup; } if (APartnerRow.PartnerClass == SharedTypes.PartnerClassEnumToString(TPartnerClass.ORGANISATION)) { if (AIsFoundation) { if (AFoundationRow != null) { if (!CheckFoundationSecurity(AFoundationRow)) { TLogging.LogAtLevel(6, "CanAccessPartner: Access DENIED - Partner " + APartnerRow.PartnerKey.ToString() + " is restriced by Foundation Ownership!"); return TPartnerAccessLevelEnum.palRestrictedByFoundationOwnership; } } else { throw new System.ArgumentException("AFoundationRow must not be null if AIsFoundation is true"); } } } TLogging.LogAtLevel(6, "CanAccessPartner: Access to Partner " + APartnerRow.PartnerKey.ToString() + " is GRANTED!"); return TPartnerAccessLevelEnum.palGranted; }
/// <summary> /// Tests whether the current user has access to a particular Foundation. /// </summary> /// <remarks>Corresponds to Progress 4GL Method 'CheckFoundationSecurity' in /// common/sp_partn.p</remarks> /// <param name="AFoundationRow">Foundation row to check for.</param> /// <returns>True if the current user has access to the passed in Foundation, /// otherwise false.</returns> public static bool CheckFoundationSecurity(PFoundationRow AFoundationRow) { return(CheckFoundationSecurity(AFoundationRow.Owner1Key, AFoundationRow.Owner2Key)); }
/// <summary> /// Tests whether the current user has access to a particular Foundation. /// </summary> /// <remarks>Corresponds to Progress 4GL Method 'CheckFoundationSecurity' in /// common/sp_partn.p</remarks> /// <param name="AFoundationRow">Foundation row to check for.</param> /// <returns>True if the current user has access to the passed in Foundation, /// otherwise false.</returns> public static bool CheckFoundationSecurity(PFoundationRow AFoundationRow) { return CheckFoundationSecurity(AFoundationRow.Owner1Key, AFoundationRow.Owner2Key); }