internal static List <object> FindRecipientsWithSendAsPermissionCloud(IEnumerable <object> permissions)
        {
            List <object> list = new List <object>();

            foreach (object obj in permissions)
            {
                RecipientPermission recipientPermission = obj as RecipientPermission;
                if (recipientPermission.AccessRights.Contains(RecipientAccessRight.SendAs))
                {
                    list.Add(new TrusteeRow(recipientPermission.Trustee));
                }
            }
            return(list);
        }
Example #2
0
        protected override void WriteResult(IConfigurable dataObject)
        {
            TaskLogger.LogEnter();
            IDirectorySession directorySession = (IDirectorySession)base.DataSession;

            if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(directorySession, (ADObject)dataObject))
            {
                directorySession = TaskHelper.UnderscopeSessionToOrganization(directorySession, ((ADObject)dataObject).OrganizationId, true);
            }
            ActiveDirectorySecurity     activeDirectorySecurity = PermissionTaskHelper.ReadAdSecurityDescriptor((ADRawEntry)dataObject, directorySession, new Task.TaskErrorLoggingDelegate(base.WriteError));
            AuthorizationRuleCollection accessRules             = activeDirectorySecurity.GetAccessRules(true, true, typeof(SecurityIdentifier));

            foreach (object obj in accessRules)
            {
                ActiveDirectoryAccessRule activeDirectoryAccessRule = (ActiveDirectoryAccessRule)obj;
                if (this.Trustee == null || this.trusteeSid == activeDirectoryAccessRule.IdentityReference)
                {
                    RecipientAccessRight?recipientAccessRight = this.FilterByRecipientAccessRights(activeDirectoryAccessRule, this.AccessRights);
                    if (recipientAccessRight != null)
                    {
                        string text = string.Empty;
                        if (Globals.IsDatacenter && base.TenantGlobalCatalogSession != null)
                        {
                            try
                            {
                                SecurityIdentifier sId         = (SecurityIdentifier)activeDirectoryAccessRule.IdentityReference;
                                ADRecipient        adrecipient = base.TenantGlobalCatalogSession.FindBySid(sId);
                                if (adrecipient != null)
                                {
                                    text = ((!string.IsNullOrEmpty(adrecipient.DisplayName)) ? adrecipient.DisplayName : adrecipient.Name);
                                }
                            }
                            catch
                            {
                            }
                        }
                        if (string.IsNullOrEmpty(text))
                        {
                            text = RecipientPermissionTaskHelper.GetFriendlyNameOfSecurityIdentifier((SecurityIdentifier)activeDirectoryAccessRule.IdentityReference, base.TenantGlobalCatalogSession, new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
                        }
                        RecipientPermission dataObject2 = new RecipientPermission(activeDirectoryAccessRule, ((ADRawEntry)dataObject).Id, text, recipientAccessRight.Value);
                        base.WriteResult(dataObject2);
                    }
                }
            }
            TaskLogger.LogExit();
        }