Ejemplo n.º 1
0
        public static TrackedUser Create(Guid guid, IRecipientSession galSession)
        {
            ADRecipient adrecipient = null;

            try
            {
                adrecipient = galSession.FindByExchangeGuid(guid);
            }
            catch (NonUniqueRecipientException arg)
            {
                TraceWrapper.SearchLibraryTracer.TraceError <Guid, NonUniqueRecipientException>(0, "Create from GUID: Caught NonUniqueRecipientException when attempting to look up server for guid {0}, exception: {1}", guid, arg);
                return(null);
            }
            if (adrecipient != null)
            {
                try
                {
                    return(new TrackedUser(adrecipient));
                }
                catch (TrackedUserCreationException arg2)
                {
                    TraceWrapper.SearchLibraryTracer.TraceError <Guid, TrackedUserCreationException>(0, "Create from GUID: TrackedUserCreationException initializing from ADRecipient: {0}, {1}", guid, arg2);
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        private static Uri GetSharepointUrl(ExchangePrincipal siteMailbox, int sessionHashCode)
        {
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, true, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(siteMailbox.MailboxInfo.OrganizationId), 541, "GetSharepointUrl", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\LinkedFolder\\SharepointAccessManager.cs");
            ADRecipient       adrecipient = null;

            try
            {
                adrecipient = tenantOrRootOrgRecipientSession.FindByExchangeGuid(siteMailbox.MailboxInfo.MailboxGuid);
            }
            catch (TransientException arg)
            {
                ExTraceGlobals.SiteMailboxPermissionCheckTracer.TraceError <TransientException>((long)sessionHashCode, "SharepointAccessManager.GetSharepointUrl: Failed to FindByExchangeGuid for site mailbox with TransientException {0}", arg);
                return(null);
            }
            catch (DataValidationException arg2)
            {
                ExTraceGlobals.SiteMailboxPermissionCheckTracer.TraceError <DataValidationException>((long)sessionHashCode, "SharepointAccessManager.GetSharepointUrl: Failed to FindByExchangeGuid for site mailbox with DataValidationException {0}", arg2);
                return(null);
            }
            catch (DataSourceOperationException arg3)
            {
                ExTraceGlobals.SiteMailboxPermissionCheckTracer.TraceError <DataSourceOperationException>((long)sessionHashCode, "SharepointAccessManager.GetSharepointUrl: Failed to FindByExchangeGuid for site mailbox with DataSourceOperationException {0}", arg3);
                return(null);
            }
            ADUser aduser = adrecipient as ADUser;

            if (aduser == null)
            {
                ExTraceGlobals.SiteMailboxPermissionCheckTracer.TraceError((long)sessionHashCode, "SharepointAccessManager.GetSharepointUrl: siteMailboxRecipientObject is not ADUser");
                return(null);
            }
            return(aduser.SharePointUrl);
        }
        // Token: 0x06001250 RID: 4688 RVA: 0x000696B4 File Offset: 0x000678B4
        private ADUser GetOrganizationalMailboxFromAD(ADSessionSettings sessionSettings, Guid mailboxGuid)
        {
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 733, "GetOrganizationalMailboxFromAD", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\OABGenerator\\OABGeneratorAssistant.cs");
            ADRecipient       adrecipient;

            try
            {
                adrecipient = tenantOrRootOrgRecipientSession.FindByExchangeGuid(mailboxGuid);
            }
            catch (NonUniqueRecipientException)
            {
                OABGeneratorAssistant.Tracer.TraceError <Guid>((long)this.GetHashCode(), "OABGeneratorAssistant.GetOrganizationalMailboxFromAD: multiple mailboxes have ExchangeGuid={0}", mailboxGuid);
                OABLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_OrganizationalMailboxGuidIsNotUnique, new object[]
                {
                    mailboxGuid
                });
                return(null);
            }
            if (adrecipient == null)
            {
                OABGeneratorAssistant.Tracer.TraceError <Guid>((long)this.GetHashCode(), "OABGeneratorAssistant.GetOrganizationalMailboxFromAD: unable to find user object with ExchangeGuid={0}", mailboxGuid);
                return(null);
            }
            ADUser aduser = adrecipient as ADUser;

            if (aduser == null)
            {
                OABGeneratorAssistant.Tracer.TraceError <Guid>((long)this.GetHashCode(), "OABGeneratorAssistant.GetOrganizationalMailboxFromAD: unknown organization mailbox: {0}", mailboxGuid);
                return(null);
            }
            return(aduser);
        }
Ejemplo n.º 4
0
        // Token: 0x06000C3A RID: 3130 RVA: 0x0004F5C4 File Offset: 0x0004D7C4
        private bool TryFindUser(MapiEvent mapiEvent, MailboxSession itemStore, out ADUser user)
        {
            IRecipientSession adrecipientSession = itemStore.GetADRecipientSession(false, ConsistencyMode.IgnoreInvalid);

            user = (adrecipientSession.FindByExchangeGuid(mapiEvent.MailboxGuid) as ADUser);
            return(user != null);
        }
Ejemplo n.º 5
0
 public static ADRecipient ReadADRecipient(Guid mailboxGuid, bool isArchive, IRecipientSession recipientSession)
 {
     if (isArchive)
     {
         return(recipientSession.FindByExchangeGuidIncludingArchive(mailboxGuid));
     }
     return(recipientSession.FindByExchangeGuid(mailboxGuid));
 }
 public ADRecipient GetContentMailboxADRecipient(IRecipientSession session = null)
 {
     if (session == null)
     {
         session = this.GetADSession();
     }
     return(session.FindByExchangeGuid(this.ContentMailboxGuid));
 }
        protected override TeamMailboxSyncInfo CreateOnCacheMiss(TeamMailboxSyncId key, ref bool shouldAdd)
        {
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(key.DomainController, true, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(key.OrgId), 105, "CreateOnCacheMiss", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\LinkedFolder\\TeamMailboxSyncInfoCache.cs");
            ADRecipient       adrecipient = tenantOrRootOrgRecipientSession.FindByExchangeGuid(key.MailboxGuid);
            ADUser            aduser      = adrecipient as ADUser;

            if (aduser == null)
            {
                return(null);
            }
            TeamMailboxLifecycleState teamMailboxLifecycleState = TeamMailboxLifecycleState.Active;

            if (TeamMailbox.IsPendingDeleteSiteMailbox(aduser))
            {
                teamMailboxLifecycleState = TeamMailboxLifecycleState.PendingDelete;
            }
            else if (aduser.SharePointUrl == null)
            {
                teamMailboxLifecycleState = TeamMailboxLifecycleState.Unlinked;
            }
            ExchangePrincipal exchangePrincipal = null;

            try
            {
                exchangePrincipal = ExchangePrincipal.FromMailboxGuid(ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(key.OrgId), key.MailboxGuid, key.DomainController);
            }
            catch (ObjectNotFoundException)
            {
                return(null);
            }
            TeamMailboxSyncInfo result;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                MailboxSession    mailboxSession    = null;
                UserConfiguration userConfiguration = null;
                if (teamMailboxLifecycleState == TeamMailboxLifecycleState.Active)
                {
                    mailboxSession = MailboxSession.OpenAsAdmin(exchangePrincipal, CultureInfo.InvariantCulture, "Client=TeamMailbox;Action=CommitChanges;Interactive=False");
                    disposeGuard.Add <MailboxSession>(mailboxSession);
                    if (!string.Equals(mailboxSession.MailboxOwner.MailboxInfo.Location.ServerFqdn, TeamMailboxSyncInfoCache.LocalServerFqdn, StringComparison.OrdinalIgnoreCase))
                    {
                        throw new WrongServerException(new LocalizedString(string.Format("Non-local XSO MailboxSession not allowed for TeamMailboxSync. TeamMailbox Name: {0}, MailboxGuid {1}, ServerFqdn {2}", mailboxSession.MailboxOwner.MailboxInfo.DisplayName, mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, mailboxSession.MailboxOwner.MailboxInfo.Location.ServerFqdn)));
                    }
                    userConfiguration = UserConfigurationHelper.GetMailboxConfiguration(mailboxSession, this.syncLogConfigurationName, UserConfigurationTypes.Stream, true);
                    disposeGuard.Add <UserConfiguration>(userConfiguration);
                }
                TeamMailbox         teamMailbox         = TeamMailbox.FromDataObject(aduser);
                TeamMailboxSyncInfo teamMailboxSyncInfo = new TeamMailboxSyncInfo(key.MailboxGuid, teamMailboxLifecycleState, mailboxSession, exchangePrincipal, teamMailbox.DisplayName, teamMailbox.WebCollectionUrl, teamMailbox.WebId, (aduser.SharePointUrl != null) ? aduser.SharePointUrl.AbsoluteUri : null, (teamMailboxLifecycleState == TeamMailboxLifecycleState.Active) ? this.resourceMonitorFactory.Create(exchangePrincipal.MailboxInfo.MailboxDatabase.ObjectGuid) : null, userConfiguration);
                disposeGuard.Success();
                result = teamMailboxSyncInfo;
            }
            return(result);
        }
        private static ADSessionSettings GetADSessionSettings(IExchangePrincipal exchangePrincipal)
        {
            OrganizationId organizationId = exchangePrincipal.MailboxInfo.OrganizationId;

            if (organizationId == null)
            {
                organizationId = OrganizationId.ForestWideOrgId;
            }
            ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(organizationId);
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.PartiallyConsistent, sessionSettings, 367, "GetADSessionSettings", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Contacts\\DirectoryPersonSearcher.cs");

            DirectoryPersonSearcher.Tracer.TraceDebug <Guid, OrganizationId>(0L, "Searching for mailbox {0} in organization {1}", exchangePrincipal.MailboxInfo.MailboxGuid, organizationId);
            ADUser aduser = tenantOrRootOrgRecipientSession.FindByExchangeGuid(exchangePrincipal.MailboxInfo.MailboxGuid) as ADUser;

            if (aduser == null)
            {
                DirectoryPersonSearcher.Tracer.TraceError(0L, "Unable to get FromOrganizationIdWithAddressListScopeServiceOnly because ExchangePrincipal is not complete.");
                return(null);
            }
            IConfigurationSession    tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 380, "GetADSessionSettings", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Contacts\\DirectoryPersonSearcher.cs");
            AddressBookMailboxPolicy addressBookMailboxPolicy             = null;

            if (aduser.AddressBookPolicy != null)
            {
                addressBookMailboxPolicy = tenantOrTopologyConfigurationSession.Read <AddressBookMailboxPolicy>(aduser.AddressBookPolicy);
            }
            ADObjectId adobjectId;

            if (addressBookMailboxPolicy != null)
            {
                adobjectId = addressBookMailboxPolicy.GlobalAddressList;
            }
            else
            {
                adobjectId = null;
            }
            if (adobjectId != null)
            {
                DirectoryPersonSearcher.Tracer.TraceDebug <ADObjectId>(0L, "Using GAL from ABP {0} for directory search.", adobjectId);
                return(ADSessionSettings.FromOrganizationIdWithAddressListScope(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), organizationId, adobjectId, null));
            }
            DirectoryPersonSearcher.Tracer.TraceDebug(0L, "Using organization scope for directory search.");
            return(ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(organizationId));
        }
Ejemplo n.º 9
0
        public override string Lookup(out SecurityIdentifier sid)
        {
            sid = null;
            ADUser aduser;

            try
            {
                ADSessionSettings sessionSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(this.domain);
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.PartiallyConsistent, sessionSettings, 67, "Lookup", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\ObscureUrlKey.cs");
                aduser = (tenantOrRootOrgRecipientSession.FindByExchangeGuid(this.mailboxGuid) as ADUser);
                if (aduser == null)
                {
                    ExTraceGlobals.SharingTracer.TraceError <Guid>((long)this.GetHashCode(), "ObscureUrlKey.Lookup(): Cannot find User object for mailbox guid {0}.", this.mailboxGuid);
                    return(null);
                }
            }
            catch (CannotResolveTenantNameException arg)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, Guid, CannotResolveTenantNameException>((long)this.GetHashCode(), "ObscureUrlKey.Lookup(): Cannot resolve tenant name {0} for mailbox guid {1}.Error: {2}", this.domain, this.mailboxGuid, arg);
                return(null);
            }
            catch (ADTransientException arg2)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, Guid, ADTransientException>((long)this.GetHashCode(), "ObscureUrlKey.Lookup(): Transient exception {0} for mailbox guid {1}.Error: {2}", this.domain, this.mailboxGuid, arg2);
                return(null);
            }
            catch (DataSourceOperationException arg3)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, Guid, DataSourceOperationException>((long)this.GetHashCode(), "ObscureUrlKey.Lookup(): DataSourceOperationException  {0} for mailbox guid {1}.Error: {2}", this.domain, this.mailboxGuid, arg3);
                return(null);
            }
            sid = aduser.Sid;
            string folder = aduser.SharingAnonymousIdentities.GetFolder(this.urlId);

            if (string.IsNullOrEmpty(folder))
            {
                ExTraceGlobals.SharingTracer.TraceDebug <Guid, string>((long)this.GetHashCode(), "ObscureUrlKey.Lookup(): Not found sharing anonymous identity for mailbox guid {0} with url id {1}.", this.mailboxGuid, this.urlId);
            }
            else
            {
                ExTraceGlobals.SharingTracer.TraceDebug <Guid, string, string>((long)this.GetHashCode(), "ObscureUrlKey.Lookup(): Get sharing anonymous identity for mailbox guid {0} with url id {1}: Folder Id = {2}.", this.mailboxGuid, this.urlId, folder);
            }
            return(folder);
        }
Ejemplo n.º 10
0
        // Token: 0x0600113D RID: 4413 RVA: 0x00064C58 File Offset: 0x00062E58
        private void SetUMGrammarReadyFlag()
        {
            Exception ex = null;

            try
            {
                ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), base.OrgId, null, false);
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.IgnoreInvalid, sessionSettings, 979, "SetUMGrammarReadyFlag", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\DirectoryProcessor\\UmGrammarGenerator\\GrammarGenerator.cs");
                ADUser            aduser = tenantOrRootOrgRecipientSession.FindByExchangeGuid(base.MailboxGuid) as ADUser;
                if (aduser != null && !aduser.PersistedCapabilities.Contains(Capability.OrganizationCapabilityUMGrammarReady))
                {
                    aduser.PersistedCapabilities.Add(Capability.OrganizationCapabilityUMGrammarReady);
                    tenantOrRootOrgRecipientSession.Save(aduser);
                }
            }
            catch (ADTransientException ex2)
            {
                ex = ex2;
            }
            catch (ADOperationException ex3)
            {
                ex = ex3;
            }
            finally
            {
                if (ex != null)
                {
                    UmGlobals.ExEvent.LogEvent(UMEventLogConstants.Tuple_SetUMGrammarReadyFlagFailed, null, new object[]
                    {
                        base.RunData.TenantId,
                        base.RunData.MailboxGuid,
                        base.RunData.RunId,
                        CommonUtil.ToEventLogString(ex)
                    });
                }
            }
        }
        // Token: 0x06001869 RID: 6249 RVA: 0x0008F2EC File Offset: 0x0008D4EC
        private void ProcessGet()
        {
            using (this.user.Context.Tracker.Start(TimeId.UserInformationSettingsProcessGet))
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Processing UserInformationSetting - Get");
                XmlNode xmlNode  = base.Response.OwnerDocument.CreateElement("Get", "Settings:");
                bool    flag     = this.version > 140;
                XmlNode xmlNode2 = null;
                XmlNode xmlNode3 = null;
                if (flag)
                {
                    xmlNode2 = base.Response.OwnerDocument.CreateElement("Accounts", "Settings:");
                    xmlNode3 = base.Response.OwnerDocument.CreateElement("Account", "Settings:");
                }
                XmlNode           xmlNode4 = base.Response.OwnerDocument.CreateElement("EmailAddresses", "Settings:");
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(this.user.OrganizationId), 203, "ProcessGet", "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\UserInformationSetting.cs");
                ADRecipient       adrecipient = tenantOrRootOrgRecipientSession.FindByExchangeGuid(this.user.ADUser.ExchangeGuid);
                base.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, tenantOrRootOrgRecipientSession.LastUsedDc);
                if (adrecipient != null && adrecipient.EmailAddresses != null)
                {
                    using (MultiValuedProperty <ProxyAddress> .Enumerator enumerator = adrecipient.EmailAddresses.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            ProxyAddress proxyAddress = enumerator.Current;
                            AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, this, "Found proxy address {0}!", proxyAddress.AddressString);
                            if (SmtpAddress.IsValidSmtpAddress(proxyAddress.AddressString))
                            {
                                if (this.version > 140 && proxyAddress.IsPrimaryAddress && proxyAddress.Prefix.DisplayName == "SMTP")
                                {
                                    AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, this, "Found valid Primary Smtp proxy address {0}!", proxyAddress.AddressString);
                                    XmlNode xmlNode5 = base.Response.OwnerDocument.CreateElement("PrimarySmtpAddress", "Settings:");
                                    xmlNode5.InnerText = proxyAddress.AddressString;
                                    xmlNode4.AppendChild(xmlNode5);
                                }
                                else
                                {
                                    AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, this, "Found valid Smtp proxy address {0}!", proxyAddress.AddressString);
                                    XmlNode xmlNode6 = base.Response.OwnerDocument.CreateElement("SmtpAddress", "Settings:");
                                    xmlNode6.InnerText = proxyAddress.AddressString;
                                    xmlNode4.AppendChild(xmlNode6);
                                }
                            }
                        }
                        goto IL_263;
                    }
                }
                AirSyncDiagnostics.TraceDebug <bool, bool>(ExTraceGlobals.RequestsTracer, this, "fullRecipient fullRecipient.EmailAddresses is null! fullRecipient == null: {0}, fullRecipient.EmailAddresses == null : {1}", adrecipient == null, adrecipient != null && adrecipient.EmailAddresses == null);
IL_263:
                if (flag)
                {
                    xmlNode3.AppendChild(xmlNode4);
                    xmlNode2.AppendChild(xmlNode3);
                }
                if (flag)
                {
                    List <AggregationSubscription> allSubscriptions = SubscriptionManager.GetAllSubscriptions(this.mailboxSession, AggregationSubscriptionType.AllEMail);
                    foreach (AggregationSubscription aggregationSubscription in allSubscriptions)
                    {
                        PimAggregationSubscription pimAggregationSubscription = aggregationSubscription as PimAggregationSubscription;
                        if (pimAggregationSubscription == null)
                        {
                            AirSyncDiagnostics.TraceInfo <Guid>(ExTraceGlobals.RequestsTracer, this, "Found AggregationSubscription that was not a PimAggregationSubscription {0}!", pimAggregationSubscription.SubscriptionGuid);
                        }
                        else
                        {
                            AirSyncDiagnostics.TraceInfo <Guid>(ExTraceGlobals.RequestsTracer, this, "Found valid subscription {0}!", pimAggregationSubscription.SubscriptionGuid);
                            XmlNode xmlNode7 = base.Response.OwnerDocument.CreateElement("Account", "Settings:");
                            XmlNode xmlNode8 = base.Response.OwnerDocument.CreateElement("AccountId", "Settings:");
                            xmlNode8.InnerText = pimAggregationSubscription.SubscriptionGuid.ToString();
                            xmlNode7.AppendChild(xmlNode8);
                            XmlNode xmlNode9 = base.Response.OwnerDocument.CreateElement("AccountName", "Settings:");
                            xmlNode9.InnerText = pimAggregationSubscription.Name;
                            xmlNode7.AppendChild(xmlNode9);
                            XmlNode xmlNode10 = base.Response.OwnerDocument.CreateElement("UserDisplayName", "Settings:");
                            xmlNode10.InnerText = pimAggregationSubscription.UserDisplayName;
                            xmlNode7.AppendChild(xmlNode10);
                            if (!pimAggregationSubscription.SendAsCapable || !SubscriptionManager.IsValidForSendAs(pimAggregationSubscription.SendAsState, pimAggregationSubscription.Status))
                            {
                                XmlNode newChild = base.Response.OwnerDocument.CreateElement("SendDisabled", "Settings:");
                                xmlNode7.AppendChild(newChild);
                            }
                            XmlNode xmlNode11 = base.Response.OwnerDocument.CreateElement("PrimarySmtpAddress", "Settings:");
                            xmlNode11.InnerText = pimAggregationSubscription.UserEmailAddress.ToString();
                            xmlNode4            = base.Response.OwnerDocument.CreateElement("EmailAddresses", "Settings:");
                            xmlNode4.AppendChild(xmlNode11);
                            xmlNode7.AppendChild(xmlNode4);
                            xmlNode2.AppendChild(xmlNode7);
                        }
                    }
                }
                XmlNode xmlNode12 = base.Response.OwnerDocument.CreateElement("Status", "Settings:");
                XmlNode xmlNode13 = xmlNode12;
                int     num       = (int)this.status;
                xmlNode13.InnerText = num.ToString(CultureInfo.InvariantCulture);
                base.Response.AppendChild(xmlNode12);
                if (flag)
                {
                    xmlNode.AppendChild(xmlNode2);
                }
                else
                {
                    xmlNode.AppendChild(xmlNode4);
                }
                base.Response.AppendChild(xmlNode);
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Done processing UserInformationSetting - Get.");
            }
        }
Ejemplo n.º 12
0
        public UnifiedGroupMemberType GetMembershipType()
        {
            if (this.DenyCurrentLogon())
            {
                GroupMailboxAuthorizationHandler.Tracer.TraceWarning <string>(0L, "Not OWA logon and flight not enabled for group. ClientInfoString:{0} ", this.clientInfoString);
                return(UnifiedGroupMemberType.Unknown);
            }
            IRecipientSession recipientSession = AccessingUserInfo.GetRecipientSession(this.organizationId);

            ArgumentValidator.ThrowIfNull("recipientSession", recipientSession);
            ArgumentValidator.ThrowIfInvalidValue <IRecipientSession>("recipientSession.ReadOnly", recipientSession, (IRecipientSession x) => x.ReadOnly);
            if (this.accessingUserInfo.UserObjectId != null)
            {
                ADRecipient adrecipient = recipientSession.FindByExchangeGuid(this.groupMailboxToLogon.MailboxInfo.MailboxGuid);
                if (adrecipient != null)
                {
                    recipientSession.DomainController = adrecipient.OriginatingServer;
                    MultiValuedProperty <ADObjectId> multiValuedProperty = (MultiValuedProperty <ADObjectId>)adrecipient[ADUserSchema.Owners];
                    if (multiValuedProperty.Contains(this.accessingUserInfo.UserObjectId))
                    {
                        this.TraceMembershipType(UnifiedGroupMemberType.Owner);
                        return(UnifiedGroupMemberType.Owner);
                    }
                }
                if (this.groupMailboxToLogon.ModernGroupType == ModernGroupObjectType.Public)
                {
                    this.TraceMembershipType(UnifiedGroupMemberType.Member);
                    return(UnifiedGroupMemberType.Member);
                }
                if (this.groupMailboxToLogon.ModernGroupType == ModernGroupObjectType.Private)
                {
                    QueryFilter  queryFilter  = new ComparisonFilter(ComparisonOperator.Equal, IUnifiedGroupMailboxSchema.UnifiedGroupMembersLink, this.accessingUserInfo.UserObjectId);
                    QueryFilter  queryFilter2 = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Id, this.groupMailboxToLogon.ObjectId);
                    ADRawEntry[] array        = recipientSession.Find(null, QueryScope.SubTree, new AndFilter(new QueryFilter[]
                    {
                        queryFilter2,
                        queryFilter
                    }), null, 0, GroupMailboxAuthorizationHandler.PropertiesToReturnForGroupQuery);
                    if (array != null && array.Length == 1)
                    {
                        this.TraceMembershipType(UnifiedGroupMemberType.Member);
                        return(UnifiedGroupMemberType.Member);
                    }
                }
            }
            else
            {
                GroupMailboxAuthorizationHandler.Tracer.TraceError <string>((long)this.GetHashCode(), "Unable to retrieve object identity of user {0} from AD", this.accessingUserInfo.Identity);
            }
            if (this.groupMailboxToLogon.ModernGroupType == ModernGroupObjectType.Public)
            {
                this.TraceMembershipType(UnifiedGroupMemberType.Member);
                return(UnifiedGroupMemberType.Member);
            }
            if (this.groupMailboxToLogon.ModernGroupType == ModernGroupObjectType.Private && this.IsGroupMemberInMailboxAssociation())
            {
                this.TraceMembershipType(UnifiedGroupMemberType.Member);
                return(UnifiedGroupMemberType.Member);
            }
            this.TraceMembershipType(UnifiedGroupMemberType.None);
            return(UnifiedGroupMemberType.None);
        }
        public override IAsyncResult BeginExecute(AsyncCallback executeCallback, object state)
        {
            this.executionAsyncResult = new LazyAsyncResult(null, state, executeCallback);
            this.performanceCounter.Start(OperationType.EndToEnd);
            try
            {
                this.InitializeSyncMetadata();
                base.UpdateSyncMetadataOnBeginSync();
            }
            catch (StorageTransientException ex)
            {
                ProtocolLog.LogError(this.loggingComponent, this.loggingContext, "MaintenanceSynchronizer.BeginExecute: failed with StorageTransientException", ex);
                this.executionAsyncResult.InvokeCallback(ex);
                return(this.executionAsyncResult);
            }
            catch (StoragePermanentException ex2)
            {
                ProtocolLog.LogError(this.loggingComponent, this.loggingContext, "MaintenanceSynchronizer.BeginExecute: failed with StoragePermanentException", ex2);
                this.executionAsyncResult.InvokeCallback(ex2);
                return(this.executionAsyncResult);
            }
            ProtocolLog.LogInformation(this.loggingComponent, this.loggingContext, "MaintenanceSynchronizer.BeginExecute");
            Exception value = null;
            Uri       uri;
            string    b;

            if (this.recordedSiteUrl != null && this.webCollectionUrl != null && this.TryGetSharePointSiteUrlAndTitle(this.webCollectionUrl, this.webId, out uri, out b, out value))
            {
                if (UriComparer.IsEqual(this.recordedSiteUrl, uri))
                {
                    if (string.Equals(this.displayName, b))
                    {
                        goto IL_286;
                    }
                }
                try
                {
                    IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, null, CultureInfo.InvariantCulture.LCID, false, ConsistencyMode.IgnoreInvalid, null, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(this.orgId), 189, "BeginExecute", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\LinkedFolder\\MaintenanceSynchronizer.cs");
                    ADUser            aduser = tenantOrRootOrgRecipientSession.FindByExchangeGuid(this.TeamMailboxGuid) as ADUser;
                    if (aduser == null)
                    {
                        value = new ObjectNotFoundException(new LocalizedString("Cannot find the team mailbox by mailbox guid " + this.TeamMailboxGuid));
                    }
                    else
                    {
                        aduser.SharePointUrl = uri;
                        aduser.DisplayName   = b;
                        tenantOrRootOrgRecipientSession.Save(aduser);
                        ProtocolLog.LogInformation(this.loggingComponent, this.loggingContext, "MaintenanceSynchronizer.BeginExecute: updated new SharePoint site URL: " + uri);
                        if (!UriComparer.IsEqual(this.recordedSiteUrl, uri))
                        {
                            RpcClientWrapper.EnqueueTeamMailboxSyncRequest(this.mailboxSession.MailboxOwner.MailboxInfo.Location.ServerFqdn, this.mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, QueueType.TeamMailboxDocumentSync, this.mailboxSession.MailboxOwner.MailboxInfo.OrganizationId, "Maintenance Synchronizer", tenantOrRootOrgRecipientSession.LastUsedDc, SyncOption.Default);
                            RpcClientWrapper.EnqueueTeamMailboxSyncRequest(this.mailboxSession.MailboxOwner.MailboxInfo.Location.ServerFqdn, this.mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, QueueType.TeamMailboxMembershipSync, this.mailboxSession.MailboxOwner.MailboxInfo.OrganizationId, "Maintenance Synchronizer", tenantOrRootOrgRecipientSession.LastUsedDc, SyncOption.Default);
                        }
                    }
                }
                catch (DataSourceOperationException ex3)
                {
                    value = ex3;
                }
                catch (DataValidationException ex4)
                {
                    value = ex4;
                }
                catch (TransientException ex5)
                {
                    value = ex5;
                }
            }
IL_286:
            this.executionAsyncResult.InvokeCallback(value);
            return(this.executionAsyncResult);
        }
Ejemplo n.º 14
0
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            try
            {
                base.ValidateRootFolders(this.SourceRootFolder, this.TargetRootFolder);
                bool wildcardedSearch = false;
                if (!string.IsNullOrEmpty(base.Name))
                {
                    base.ValidateName();
                    base.RequestName = base.Name;
                }
                else
                {
                    wildcardedSearch = true;
                    base.RequestName = "MailboxRestore";
                }
                this.targetUser = RequestTaskHelper.ResolveADUser(base.RecipSession, base.GCSession, base.ServerSettings, this.TargetMailbox, base.OptionalIdentityData, base.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), true);
                this.CheckForInvalidPublicFolderRestoreParameters();
                if (this.targetUser.HasLocalArchive && this.targetUser.RecipientType == RecipientType.MailUser && this.targetUser.Database == null && !this.TargetIsArchive)
                {
                    base.WriteError(new MissingArchiveParameterForRestorePermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox);
                }
                if (this.targetUser.RecipientType != RecipientType.UserMailbox && (!this.TargetIsArchive || this.targetUser.RecipientType != RecipientType.MailUser))
                {
                    base.WriteError(new InvalidRecipientTypePermanentException(this.targetUser.ToString(), this.targetUser.RecipientType.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox);
                }
                if (this.TargetIsArchive && (this.targetUser.ArchiveGuid == Guid.Empty || this.targetUser.ArchiveDatabase == null))
                {
                    base.WriteError(new MailboxLacksArchivePermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetIsArchive);
                }
                if (!this.TargetIsArchive && this.targetUser.Database == null)
                {
                    base.WriteError(new MailboxLacksDatabasePermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox);
                }
                if (base.ParameterSetName.Equals("RemoteMailboxRestore"))
                {
                    if (!Guid.TryParse(this.SourceStoreMailbox.RawIdentity, out this.sourceMailboxGuid))
                    {
                        base.WriteError(new RecipientTaskException(Strings.ErrorParameterValueNotAllowed("SourceStoreMailbox")), ErrorCategory.InvalidArgument, this.SourceStoreMailbox);
                    }
                    if (!base.Fields.IsModified("AllowLegacyDNMismatch") || !this.AllowLegacyDNMismatch)
                    {
                        base.WriteError(new RecipientTaskException(Strings.ErrorParameterValueNotAllowed("AllowLegacyDNMismatch")), ErrorCategory.InvalidArgument, this.AllowLegacyDNMismatch);
                    }
                    base.Flags = (RequestFlags.CrossOrg | RequestFlags.Pull);
                    switch (this.RemoteRestoreType)
                    {
                    case RemoteRestoreType.RecoveryDatabase:
                        this.restoreFlags |= MailboxRestoreType.Recovery;
                        this.restoreFlags |= MailboxRestoreType.SoftDeleted;
                        break;

                    case RemoteRestoreType.DisconnectedMailbox:
                        this.restoreFlags |= MailboxRestoreType.SoftDeleted;
                        break;

                    case RemoteRestoreType.SoftDeletedRecipient:
                        this.restoreFlags |= MailboxRestoreType.SoftDeletedRecipient;
                        break;

                    default:
                        base.WriteError(new RecipientTaskException(Strings.ErrorParameterValueNotAllowed("RemoteRestoreType")), ErrorCategory.InvalidArgument, this.RemoteRestoreType);
                        break;
                    }
                }
                else
                {
                    base.Flags = (RequestFlags.IntraOrg | RequestFlags.Pull);
                    string          fqdn;
                    string          serverExchangeLegacyDn;
                    ADObjectId      adobjectId;
                    int             num;
                    MailboxDatabase mailboxDatabase = base.CheckDatabase <MailboxDatabase>(this.SourceDatabase, NewRequest <MailboxRestoreRequest> .DatabaseSide.Source, this.SourceDatabase, out fqdn, out serverExchangeLegacyDn, out adobjectId, out num);
                    if (mailboxDatabase.Recovery)
                    {
                        this.restoreFlags |= MailboxRestoreType.Recovery;
                    }
                    this.sourceDatabase            = mailboxDatabase.Id;
                    this.SourceStoreMailbox.Flags |= 1UL;
                    using (MapiSession mapiSession = new MapiAdministrationSession(serverExchangeLegacyDn, Fqdn.Parse(fqdn)))
                    {
                        using (MailboxStatistics mailboxStatistics = (MailboxStatistics)base.GetDataObject <MailboxStatistics>(this.SourceStoreMailbox, mapiSession, MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(mailboxDatabase), new LocalizedString?(Strings.ErrorStoreMailboxNotFound(this.SourceStoreMailbox.ToString(), this.SourceDatabase.ToString())), new LocalizedString?(Strings.ErrorStoreMailboxNotUnique(this.SourceStoreMailbox.ToString(), this.SourceDatabase.ToString()))))
                        {
                            MailboxState?disconnectReason = mailboxStatistics.DisconnectReason;
                            if (mailboxStatistics.MailboxType == StoreMailboxType.PublicFolderPrimary || mailboxStatistics.MailboxType == StoreMailboxType.PublicFolderSecondary)
                            {
                                this.restoreFlags |= MailboxRestoreType.PublicFolderMailbox;
                            }
                            bool flag = false;
                            if (disconnectReason == null && !mailboxDatabase.Recovery)
                            {
                                mapiSession.Administration.SyncMailboxWithDS(mailboxDatabase.Guid, mailboxStatistics.MailboxGuid);
                                using (MailboxStatistics mailboxStatistics2 = (MailboxStatistics)base.GetDataObject <MailboxStatistics>(this.SourceStoreMailbox, mapiSession, MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(mailboxDatabase), new LocalizedString?(Strings.ErrorStoreMailboxNotFound(this.SourceStoreMailbox.ToString(), this.SourceDatabase.ToString())), new LocalizedString?(Strings.ErrorStoreMailboxNotUnique(this.SourceStoreMailbox.ToString(), this.SourceDatabase.ToString()))))
                                {
                                    disconnectReason = mailboxStatistics2.DisconnectReason;
                                    if (disconnectReason == null)
                                    {
                                        if (this.targetUser.OrganizationId != null && this.targetUser.OrganizationId.OrganizationalUnit != null && VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled)
                                        {
                                            IRecipientSession recipientSession = CommonUtils.CreateRecipientSession(mailboxStatistics.ExternalDirectoryOrganizationId, null, null);
                                            ADRecipient       adrecipient      = this.TargetIsArchive ? recipientSession.FindByExchangeGuidIncludingArchive(mailboxStatistics.MailboxGuid) : recipientSession.FindByExchangeGuid(mailboxStatistics.MailboxGuid);
                                            flag = (adrecipient != null && adrecipient.RecipientSoftDeletedStatus != 0);
                                        }
                                        if (!this.IsPublicFolderMailboxRestore && !flag)
                                        {
                                            base.WriteError(new CannotRestoreConnectedMailboxPermanentException(this.SourceStoreMailbox.ToString()), ErrorCategory.InvalidArgument, this.SourceStoreMailbox);
                                        }
                                    }
                                }
                            }
                            if (flag)
                            {
                                this.restoreFlags |= MailboxRestoreType.SoftDeletedRecipient;
                            }
                            else if (disconnectReason != null)
                            {
                                if (disconnectReason != MailboxState.SoftDeleted)
                                {
                                    this.restoreFlags |= MailboxRestoreType.Disabled;
                                }
                                else
                                {
                                    this.restoreFlags |= MailboxRestoreType.SoftDeleted;
                                }
                            }
                            this.sourceMailboxGuid = mailboxStatistics.MailboxGuid;
                            this.sourceMailboxDN   = mailboxStatistics.LegacyDN;
                        }
                    }
                    if ((this.TargetIsArchive && this.sourceMailboxGuid == this.targetUser.ArchiveGuid && this.sourceDatabase.Equals(this.targetUser.ArchiveDatabase)) || (!this.TargetIsArchive && this.sourceMailboxGuid == this.targetUser.ExchangeGuid && this.sourceDatabase.Equals(this.targetUser.Database)))
                    {
                        base.WriteError(new CannotRestoreIntoSelfPermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox);
                    }
                }
                if (this.restoreFlags.HasFlag(MailboxRestoreType.PublicFolderMailbox))
                {
                    if (this.targetUser.RecipientTypeDetails != RecipientTypeDetails.PublicFolderMailbox)
                    {
                        base.WriteError(new RecipientTaskException(Strings.ErrorCannotRestoreFromPublicToPrivateMailbox), ErrorCategory.InvalidArgument, this.SourceStoreMailbox);
                    }
                }
                else if (this.targetUser.RecipientTypeDetails == RecipientTypeDetails.PublicFolderMailbox)
                {
                    base.WriteError(new RecipientTaskException(Strings.ErrorCannotRestoreFromPrivateToPublicMailbox), ErrorCategory.InvalidArgument, this.SourceStoreMailbox);
                }
                base.RescopeToOrgId(this.targetUser.OrganizationId);
                if (base.ParameterSetName.Equals("RemoteMailboxRestore"))
                {
                    base.PerRecordReportEntries.Add(new ReportEntry(MrsStrings.ReportRequestAllowedMismatch(base.ExecutingUserIdentity)));
                }
                else
                {
                    base.ValidateLegacyDNMatch(this.sourceMailboxDN, this.targetUser, this.TargetMailbox);
                }
                ADObjectId mdbId         = null;
                ADObjectId mdbServerSite = null;
                this.LocateAndChooseMdb(null, this.TargetIsArchive ? this.targetUser.ArchiveDatabase : this.targetUser.Database, null, this.TargetMailbox, this.TargetMailbox, out mdbId, out mdbServerSite);
                base.MdbId         = mdbId;
                base.MdbServerSite = mdbServerSite;
                base.RequestName   = this.CheckRequestNameAvailability(base.RequestName, this.targetUser.Id, true, MRSRequestType.MailboxRestore, this.TargetMailbox, wildcardedSearch);
                base.InternalValidate();
            }
            finally
            {
                TaskLogger.LogExit();
            }
        }