コード例 #1
0
 // Token: 0x06001F77 RID: 8055 RVA: 0x000775D4 File Offset: 0x000757D4
 internal override void Validate()
 {
     if (string.IsNullOrWhiteSpace(this.Name))
     {
         throw FaultExceptionUtilities.CreateFault(new InvalidRequestException(), FaultParty.Sender);
     }
     if (string.IsNullOrWhiteSpace(this.Alias) || !CreateUnifiedGroupRequest.ValidAliasRegex.IsMatch(this.Alias))
     {
         throw FaultExceptionUtilities.CreateFault(new InvalidRequestException(), FaultParty.Sender);
     }
     if (this.GroupType != ModernGroupObjectType.Public && this.GroupType != ModernGroupObjectType.Private)
     {
         throw FaultExceptionUtilities.CreateFault(new InvalidRequestException(), FaultParty.Sender);
     }
     if (this.CultureId != null)
     {
         try
         {
             this.Language = CultureInfo.CreateSpecificCulture(this.CultureId);
         }
         catch (CultureNotFoundException innerException)
         {
             throw FaultExceptionUtilities.CreateFault(new InvalidRequestException(innerException), FaultParty.Sender);
         }
     }
 }
コード例 #2
0
        // Token: 0x06001B94 RID: 7060 RVA: 0x00069C84 File Offset: 0x00067E84
        public static string CleanHtml(string input)
        {
            string     text       = null;
            HtmlToHtml htmlToHtml = new HtmlToHtml();

            htmlToHtml.FilterHtml         = true;
            htmlToHtml.OutputHtmlFragment = true;
            string result;

            using (TextReader textReader = new StringReader(input))
            {
                using (TextWriter textWriter = new StringWriter())
                {
                    try
                    {
                        htmlToHtml.Convert(textReader, textWriter);
                        text = textWriter.ToString();
                    }
                    catch (ExchangeDataException innerException)
                    {
                        throw FaultExceptionUtilities.CreateFault(new OwaCannotSanitizeHtmlException("Sanitization of the HTML failed", innerException, htmlToHtml), FaultParty.Sender);
                    }
                    result = text;
                }
            }
            return(result);
        }
コード例 #3
0
 public UploadPhoto(CallContext callContext, UploadPhotoRequest uploadPhotoRequest) : base(callContext)
 {
     this.uploadPhotoRequest = uploadPhotoRequest;
     if (string.IsNullOrEmpty(this.uploadPhotoRequest.EmailAddress))
     {
         throw FaultExceptionUtilities.CreateFault(new OwaInvalidRequestException(), FaultParty.Sender);
     }
     this.adRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(base.CallContext.AccessingPrincipal.MailboxInfo.OrganizationId), 60, ".ctor", "f:\\15.00.1497\\sources\\dev\\clients\\src\\Owa2\\Server\\Core\\ServiceCommands\\UploadPhoto.cs");
 }
コード例 #4
0
 internal override void Validate()
 {
     if (string.IsNullOrEmpty(this.SmtpAddress))
     {
         throw FaultExceptionUtilities.CreateFault(new InvalidRequestException(), FaultParty.Sender);
     }
     if (this.Filter == null)
     {
         this.Filter = string.Empty;
     }
 }
コード例 #5
0
 // Token: 0x06001F87 RID: 8071 RVA: 0x00077703 File Offset: 0x00075903
 internal override void Validate()
 {
     if (string.IsNullOrEmpty(this.ExternalDirectoryObjectId))
     {
         throw FaultExceptionUtilities.CreateFault(new InvalidRequestException(), FaultParty.Sender);
     }
     if (this.AddedMembers == null)
     {
         this.AddedMembers = new string[0];
     }
 }
コード例 #6
0
        // Token: 0x06001B74 RID: 7028 RVA: 0x00068BC0 File Offset: 0x00066DC0
        private void ValidateRequest(HttpRequest request)
        {
            UploadPhotoCommand uploadPhotoCommand;

            if (!Enum.TryParse <UploadPhotoCommand>(request.Form["UploadPhotoCommand"], true, out uploadPhotoCommand))
            {
                throw FaultExceptionUtilities.CreateFault(new OwaInvalidRequestException(), FaultParty.Sender);
            }
            if (uploadPhotoCommand != UploadPhotoCommand.UploadPreview || request.Files.Count == 0 || request.Files[0].InputStream == null)
            {
                throw FaultExceptionUtilities.CreateFault(new OwaInvalidRequestException(), FaultParty.Sender);
            }
        }
コード例 #7
0
        protected override UploadPhotoResponse InternalExecute()
        {
            DisposeGuard      disposeGuard = default(DisposeGuard);
            Action            action       = null;
            ExchangePrincipal exchangePrincipal;
            MailboxSession    mailboxSession;

            if (this.IsRequestForCurrentUser())
            {
                exchangePrincipal = base.CallContext.AccessingPrincipal;
                mailboxSession    = base.CallContext.SessionCache.GetMailboxSessionBySmtpAddress(this.uploadPhotoRequest.EmailAddress);
            }
            else
            {
                ProxyAddress proxyAddress = ProxyAddress.Parse(this.uploadPhotoRequest.EmailAddress);
                ADUser       groupAdUser  = this.adRecipientSession.FindByProxyAddress(proxyAddress) as ADUser;
                if (groupAdUser == null)
                {
                    throw FaultExceptionUtilities.CreateFault(new OwaInvalidRequestException(), FaultParty.Sender);
                }
                if (groupAdUser.RecipientTypeDetails != RecipientTypeDetails.GroupMailbox || !this.IsOwnedModernGroup(groupAdUser))
                {
                    OwaInvalidOperationException exception = new OwaInvalidOperationException(string.Format("User does not have sufficient privileges on {0}", this.uploadPhotoRequest.EmailAddress));
                    throw FaultExceptionUtilities.CreateFault(exception, FaultParty.Sender);
                }
                if (groupAdUser.IsCached)
                {
                    this.adRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(groupAdUser.OriginatingServer, false, ConsistencyMode.IgnoreInvalid, this.adRecipientSession.SessionSettings, 102, "InternalExecute", "f:\\15.00.1497\\sources\\dev\\clients\\src\\Owa2\\Server\\Core\\ServiceCommands\\UploadPhoto.cs");
                }
                exchangePrincipal = ExchangePrincipal.FromADUser(groupAdUser, null);
                mailboxSession    = MailboxSession.OpenAsAdmin(exchangePrincipal, base.CallContext.ClientCulture, "Client=OWA;Action=GroupPhotoUpload");
                action            = delegate()
                {
                    DirectorySessionFactory.Default.GetTenantOrRootRecipientReadOnlySession(this.adRecipientSession, groupAdUser.OriginatingServer, 125, "InternalExecute", "f:\\15.00.1497\\sources\\dev\\clients\\src\\Owa2\\Server\\Core\\ServiceCommands\\UploadPhoto.cs").FindByProxyAddress(proxyAddress);
                };
                disposeGuard.Add <MailboxSession>(mailboxSession);
            }
            using (disposeGuard)
            {
                PhotoRequest request = this.CreateRequest(exchangePrincipal);
                new PhotoUploadPipeline(UploadPhoto.PhotosConfiguration, mailboxSession, this.adRecipientSession, ExTraceGlobals.UserPhotosTracer).Upload(request, Stream.Null);
                if (action != null)
                {
                    action();
                }
            }
            return(new UploadPhotoResponse());
        }
コード例 #8
0
        private PhotoRequest CreateRequest(IExchangePrincipal principal)
        {
            switch (this.uploadPhotoRequest.Command)
            {
            case UploadPhotoCommand.UploadPhoto:
                return(new PhotoRequest
                {
                    TargetPrimarySmtpAddress = principal.MailboxInfo.PrimarySmtpAddress.ToString(),
                    UploadTo = principal.ObjectId,
                    Preview = false,
                    UploadCommand = UploadCommand.Upload
                });

            case UploadPhotoCommand.UploadPreview:
                return(new PhotoRequest
                {
                    TargetPrimarySmtpAddress = principal.MailboxInfo.PrimarySmtpAddress.ToString(),
                    UploadTo = principal.ObjectId,
                    Preview = true,
                    UploadCommand = UploadCommand.Upload,
                    RawUploadedPhoto = new MemoryStream(Convert.FromBase64String(this.uploadPhotoRequest.Content))
                });

            case UploadPhotoCommand.ClearPhoto:
                return(new PhotoRequest
                {
                    Preview = false,
                    UploadCommand = UploadCommand.Clear,
                    UploadTo = principal.ObjectId,
                    TargetPrimarySmtpAddress = principal.MailboxInfo.PrimarySmtpAddress.ToString()
                });

            case UploadPhotoCommand.ClearPreview:
                return(new PhotoRequest
                {
                    TargetPrimarySmtpAddress = principal.MailboxInfo.PrimarySmtpAddress.ToString(),
                    UploadTo = principal.ObjectId,
                    Preview = true,
                    UploadCommand = UploadCommand.Clear
                });

            default:
                throw FaultExceptionUtilities.CreateFault(new OwaInvalidRequestException(), FaultParty.Sender);
            }
        }
コード例 #9
0
 public static bool IsTransientError(Exception exception)
 {
     return(exception is OwaTransientException || FaultExceptionUtilities.GetIsTransient(exception));
 }
コード例 #10
0
        // Token: 0x06001B77 RID: 7031 RVA: 0x00068CD8 File Offset: 0x00066ED8
        protected override CreateUnifiedGroupResponse InternalExecute()
        {
            CreateUnifiedGroupResponse createUnifiedGroupResponse = new CreateUnifiedGroupResponse();

            if (!this.IsModernGroupUnique())
            {
                throw FaultExceptionUtilities.CreateAvailabilityFault(new UnifiedGroupAlreadyExistsException(), FaultParty.Sender);
            }
            Stopwatch stopwatch = new Stopwatch();

            try
            {
                stopwatch.Start();
                CreateUnifiedGroupTask task = new CreateUnifiedGroupTask(base.CallContext.AccessingADUser, base.CallContext.AccessingPrincipal, base.CallContext.ADRecipientSessionContext.GetADRecipientSession());
                task.Name         = this.request.Name;
                task.Alias        = this.request.Alias;
                task.Description  = this.request.Description;
                task.Type         = ((this.request.GroupType == ModernGroupObjectType.Public) ? ModernGroupTypeInfo.Public : ModernGroupTypeInfo.Private);
                task.AADComplete += delegate()
                {
                    this.PushCreatedPersona(task.ExternalDirectoryObjectId);
                };
                task.AutoSubscribeNewGroupMembers = new bool?(this.request.AutoSubscribeNewGroupMembers);
                task.Language = this.request.Language;
                IFeature autoSubscribeSetByDefault    = VariantConfiguration.GetSnapshot(base.CallContext.AccessingPrincipal.GetContext(null), null, null).OwaClientServer.AutoSubscribeSetByDefault;
                IFeature autoSubscribeNewGroupMembers = VariantConfiguration.GetSnapshot(base.CallContext.AccessingPrincipal.GetContext(null), null, null).OwaClientServer.AutoSubscribeNewGroupMembers;
                if (autoSubscribeNewGroupMembers != null && autoSubscribeNewGroupMembers.Enabled && autoSubscribeSetByDefault != null)
                {
                    base.CallContext.ProtocolLog.Set(CreateModernGroupCommandMetadata.AutoSubscribeOptionDefault, autoSubscribeSetByDefault.Enabled);
                    base.CallContext.ProtocolLog.Set(CreateModernGroupCommandMetadata.AutoSubscribeOptionReceived, this.request.AutoSubscribeNewGroupMembers);
                }
                base.CallContext.ProtocolLog.Set(CreateModernGroupCommandMetadata.DescriptionSpecified, (!string.IsNullOrEmpty(this.request.Description)) ? 1 : 0);
                if (!task.Run())
                {
                    base.CallContext.ProtocolLog.Set(CreateModernGroupCommandMetadata.Exception, task.ErrorException);
                    base.CallContext.ProtocolLog.Set(CreateModernGroupCommandMetadata.ExceptionType, task.ErrorException.GetType());
                    base.CallContext.ProtocolLog.Set(CreateModernGroupCommandMetadata.ErrorAction, task.ErrorAction);
                    if (!string.IsNullOrEmpty(task.ErrorCode))
                    {
                        base.CallContext.ProtocolLog.Set(CreateModernGroupCommandMetadata.ErrorCode, task.ErrorCode);
                    }
                    UnifiedGroupsTask.UnifiedGroupsAction errorAction = task.ErrorAction;
                    if (errorAction == UnifiedGroupsTask.UnifiedGroupsAction.AADCreate)
                    {
                        base.CallContext.ProtocolLog.Set(CreateModernGroupCommandMetadata.ExceptionLocation, "AAD");
                        throw new InternalServerErrorException(task.ErrorException);
                    }
                    if (errorAction != UnifiedGroupsTask.UnifiedGroupsAction.ExchangeCreate)
                    {
                        base.CallContext.ProtocolLog.Set(CreateModernGroupCommandMetadata.ExceptionLocation, "Unknown");
                        throw new InvalidOperationException("Unexpected error action: " + task.ErrorAction, task.ErrorException);
                    }
                    base.CallContext.ProtocolLog.Set(CreateModernGroupCommandMetadata.ExceptionLocation, "Mailbox");
                    base.CallContext.ProtocolLog.Set(ServiceCommonMetadata.GenericErrors, task.ErrorException);
                    createUnifiedGroupResponse.Error        = "Provision failed for group " + this.request.Alias;
                    createUnifiedGroupResponse.FailureState = CreateUnifiedGroupResponse.GroupProvisionFailureState.FailedMailboxProvision;
                }
                else
                {
                    Persona persona = new Persona
                    {
                        ADObjectId   = task.ADObjectGuid,
                        Alias        = this.request.Alias,
                        DisplayName  = this.request.Name,
                        EmailAddress = new EmailAddressWrapper
                        {
                            EmailAddress = task.SmtpAddress,
                            MailboxType  = MailboxHelper.MailboxTypeType.GroupMailbox.ToString()
                        }
                    };
                    createUnifiedGroupResponse.Persona = persona;
                    createUnifiedGroupResponse.ExternalDirectoryObjectId = task.ExternalDirectoryObjectId;
                    base.CallContext.ProtocolLog.Set(CreateModernGroupCommandMetadata.GroupSmtpAddress, ExtensibleLogger.FormatPIIValue(task.SmtpAddress));
                }
                this.LogElapsedTime(CreateModernGroupCommandMetadata.GroupCreationTime, task.CreationDiagnostics.GroupCreationTime);
                this.LogElapsedTime(CreateModernGroupCommandMetadata.AADIdentityCreationTime, task.CreationDiagnostics.AADIdentityCreationTime);
                this.LogElapsedTime(CreateModernGroupCommandMetadata.AADCompleteCallbackTime, task.CreationDiagnostics.AADCompleteCallbackTime);
                this.LogElapsedTime(CreateModernGroupCommandMetadata.SharePointNotificationTime, task.CreationDiagnostics.SharePointNotificationTime);
                this.LogElapsedTime(CreateModernGroupCommandMetadata.MailboxCreationTime, task.CreationDiagnostics.MailboxCreationTime);
            }
            finally
            {
                this.LogElapsedTime(CreateModernGroupCommandMetadata.TotalProcessingTime, new TimeSpan?(stopwatch.Elapsed));
            }
            return(createUnifiedGroupResponse);
        }