Пример #1
0
        private static bool TryGetADUser(string key, out ActiveSyncMiniRecipient activeDirectoryUser)
        {
            ADUserCache.activeDirectoryCacheLock.AcquireReaderLock(-1);
            bool result;

            try
            {
                if (ADUserCache.cache2.TryGetValue(key, out activeDirectoryUser))
                {
                    result = true;
                }
                else if (ADUserCache.cache1.TryGetValue(key, out activeDirectoryUser))
                {
                    result = true;
                }
                else
                {
                    result = ADUserCache.cache0.TryGetValue(key, out activeDirectoryUser);
                }
            }
            finally
            {
                ADUserCache.activeDirectoryCacheLock.ReleaseReaderLock();
            }
            return(result);
        }
Пример #2
0
        // Token: 0x06000302 RID: 770 RVA: 0x000100E8 File Offset: 0x0000E2E8
        private string GetRedirectAddressForUserHasNoMailbox(ActiveSyncMiniRecipient activesyncMiniRecipient)
        {
            string easEndpoint = null;

            if (!VariantConfiguration.InvariantNoFlightingSnapshot.ActiveSync.RedirectForOnBoarding.Enabled)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "The hybrid on boarding redirect feature is only for OnPrem servers.");
                return(null);
            }
            if (this.context.CommandType != CommandType.Options && this.context.AirSyncVersion < GlobalSettings.MinRedirectProtocolVersion)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "The protocol version is less than 14.0 that doesn't support 451 redirect protocol call.");
                return(null);
            }
            AirSyncDiagnostics.FaultInjectionPoint(3414568253U, delegate
            {
                if (activesyncMiniRecipient != null && activesyncMiniRecipient.ExternalEmailAddress != null)
                {
                    AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, "Try to figure out eas endpoint for user: {0}.", activesyncMiniRecipient.ExternalEmailAddress.AddressString);
                    this.context.ProtocolLogger.SetValue(ProtocolLoggerData.RedirectTo, "TryToFigureOutEasEndpoint");
                    SmtpProxyAddress smtpProxyAddress = activesyncMiniRecipient.ExternalEmailAddress as SmtpProxyAddress;
                    if (smtpProxyAddress != null && !string.IsNullOrEmpty(smtpProxyAddress.AddressString))
                    {
                        OrganizationIdCacheValue organizationIdCacheValue = OrganizationIdCache.Singleton.Get(activesyncMiniRecipient.OrganizationId);
                        string domain = ((SmtpAddress)smtpProxyAddress).Domain;
                        OrganizationRelationship organizationRelationship = organizationIdCacheValue.GetOrganizationRelationship(domain);
                        if (organizationRelationship != null)
                        {
                            Uri targetOwaURL = organizationRelationship.TargetOwaURL;
                            easEndpoint      = this.TransferTargetOwaUrlToEasEndpoint(targetOwaURL);
                            AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, "Redirect to EASEndpoint : {0}.", easEndpoint);
                            this.context.ProtocolLogger.AppendValue(ProtocolLoggerData.RedirectTo, easEndpoint);
                            return;
                        }
                        AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, "OrganizationRelationShip is null for the domain {0}", domain);
                        return;
                    }
                    else
                    {
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "External email address is null");
                    }
                }
            }, delegate
            {
                Uri targetOwaUri = new Uri("http://outlook.com/owa");
                easEndpoint      = this.TransferTargetOwaUrlToEasEndpoint(targetOwaUri);
            });
            return(easEndpoint);
        }
Пример #3
0
        internal static ActiveSyncMiniRecipient TryGetADUser(IAirSyncUser user, ProtocolLogger logger)
        {
            ADUserCache.< > c__DisplayClass1 CS$ < > 8__locals1 = new ADUserCache.< > c__DisplayClass1();
            AirSyncDiagnostics.Assert(user != null, "IAirSyncUser cannot be null in GetADUser", new object[0]);
            CS$ < > 8__locals1.sid2 = user.ClientSecurityContextWrapper.UserSid;
            ActiveSyncMiniRecipient activeSyncMiniRecipient = null;

            if (!GlobalSettings.DisableCaching && ADUserCache.TryGetADUser(CS$ < > 8__locals1.sid2.Value, out activeSyncMiniRecipient))
            {
                return(activeSyncMiniRecipient);
            }
            string value = user.Name;

            if (GlobalSettings.IsWindowsLiveIDEnabled)
            {
                value = user.WindowsLiveId;
            }
            if (string.IsNullOrEmpty(value))
            {
                logger.SetValue(ProtocolLoggerData.Error, "BadAuthUsername");
                throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidCombinationOfIDs, null, false);
            }
            AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, null, "ADUserCache.TryGetADUser:: user IdentityType {0}", user.Identity.GetType().FullName);
            ADSessionSettings       sessionSettings  = ADUserCache.GetSessionSettings(GlobalSettings.IsMultiTenancyEnabled ? (user.Identity as LiveIDIdentity).UserOrganizationId : OrganizationId.ForestWideOrgId, logger);
            IRecipientSession       recipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, null, 0, true, ConsistencyMode.IgnoreInvalid, null, sessionSettings, 124, "TryGetADUser", "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ADUserCache.cs");
            ActiveSyncMiniRecipient recipient        = null;

            ADNotificationAdapter.RunADOperation(delegate()
            {
                recipient = recipientSession.FindMiniRecipientBySid <ActiveSyncMiniRecipient>(CS$ < > 8__locals1.sid2, ObjectSchema.GetInstance <ClientAccessRulesRecipientFilterSchema>().AllProperties);
            });
            logger.SetValue(ProtocolLoggerData.DomainController, recipientSession.LastUsedDc);
            if (recipient == null)
            {
                AirSyncDiagnostics.TraceDebug <SecurityIdentifier>(ExTraceGlobals.RequestsTracer, null, "ADUserCache.TryGetADUserFromSid can't find ActiveSyncMiniRecipient for sid {0}", CS$ < > 8__locals1.sid2);
                return(null);
            }
            activeSyncMiniRecipient = ((recipient.RecipientType == RecipientType.UserMailbox || recipient.RecipientType == RecipientType.MailUser) ? recipient : null);
            if (activeSyncMiniRecipient == null)
            {
                AirSyncDiagnostics.TraceDebug <RecipientType>(ExTraceGlobals.RequestsTracer, null, "ADUserCache.TryGetADUserFromSid recipient type is {0} when expected UserMailbox/MailUser", recipient.RecipientType);
                return(null);
            }
            if (!GlobalSettings.DisableCaching)
            {
                ADUserCache.AddADUserToCache(CS$ < > 8__locals1.sid2.Value, activeSyncMiniRecipient);
            }
            return(activeSyncMiniRecipient);
        }
Пример #4
0
 private static void AddADUserToCache(string key, ActiveSyncMiniRecipient activeDirectoryUser)
 {
     ADUserCache.activeDirectoryCacheLock.AcquireWriterLock(-1);
     try
     {
         if (!ADUserCache.cache2.ContainsKey(key))
         {
             ADUserCache.cache2.Add(key, activeDirectoryUser);
         }
     }
     finally
     {
         ADUserCache.activeDirectoryCacheLock.ReleaseWriterLock();
     }
 }
Пример #5
0
        // Token: 0x060003B5 RID: 949 RVA: 0x00015440 File Offset: 0x00013640
        internal static ADObject CreateAndInitializeRecipientObject <TRecipientObject>(ADPropertyBag propertyBag, ADRawEntry dummyObject, IRecipientSession recipientSession) where TRecipientObject : IConfigurable, new()
        {
            ArgumentValidator.ThrowIfNull("propertyBag", propertyBag);
            ArgumentValidator.ThrowIfNull("dummyObject", dummyObject);
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[ADObjectSchema.ObjectClass];
            ADObject adobject;

            if (dummyObject is OWAMiniRecipient)
            {
                adobject = new OWAMiniRecipient();
            }
            else if (dummyObject is ActiveSyncMiniRecipient)
            {
                adobject = new ActiveSyncMiniRecipient();
            }
            else if (dummyObject is StorageMiniRecipient)
            {
                adobject = new StorageMiniRecipient();
            }
            else if (dummyObject is TransportMiniRecipient)
            {
                adobject = new TransportMiniRecipient();
            }
            else if (dummyObject is LoadBalancingMiniRecipient)
            {
                adobject = new LoadBalancingMiniRecipient();
            }
            else if (dummyObject is MiniRecipientWithTokenGroups)
            {
                adobject = new MiniRecipientWithTokenGroups();
            }
            else if (dummyObject is FrontEndMiniRecipient)
            {
                adobject = new FrontEndMiniRecipient();
            }
            else if (dummyObject is MiniRecipient)
            {
                adobject = new MiniRecipient();
            }
            else if (dummyObject is RemovedMailbox)
            {
                adobject = new RemovedMailbox();
            }
            else if (dummyObject is DeletedRecipient)
            {
                adobject = new DeletedRecipient();
            }
            else if (multiValuedProperty.Contains(ADComputerRecipient.MostDerivedClass))
            {
                adobject = new ADComputerRecipient();
            }
            else if (multiValuedProperty.Contains(ADUser.MostDerivedClass))
            {
                adobject = new ADUser();
            }
            else if (multiValuedProperty.Contains(ADContact.MostDerivedClass))
            {
                adobject = new ADContact();
            }
            else if (multiValuedProperty.Contains(ADGroup.MostDerivedClass))
            {
                adobject = new ADGroup();
            }
            else if (multiValuedProperty.Contains(ADDynamicGroup.MostDerivedClass))
            {
                adobject = new ADDynamicGroup();
            }
            else if (multiValuedProperty.Contains(ADPublicFolder.MostDerivedClass))
            {
                adobject = new ADPublicFolder();
            }
            else if (multiValuedProperty.Contains(ADSystemAttendantMailbox.MostDerivedClass))
            {
                adobject = new ADSystemAttendantMailbox();
            }
            else if (multiValuedProperty.Contains(ADSystemMailbox.MostDerivedClass))
            {
                adobject = new ADSystemMailbox();
            }
            else if (multiValuedProperty.Contains(ADPublicDatabase.MostDerivedClass))
            {
                adobject = new ADPublicDatabase();
            }
            else
            {
                if (!multiValuedProperty.Contains(ADMicrosoftExchangeRecipient.MostDerivedClass))
                {
                    string objectClass = string.Empty;
                    foreach (string text in multiValuedProperty)
                    {
                        objectClass = text;
                    }
                    ObjectValidationError error = new ObjectValidationError(DirectoryStrings.UnsupportedObjectClass(objectClass), (ADObjectId)propertyBag[ADObjectSchema.Id], string.Empty);
                    ADProviderPerf.UpdateProcessCounter(Counter.ProcessRateCriticalValidationFailures, UpdateType.Update, 1U);
                    Globals.LogEvent(DirectoryEventLogConstants.Tuple_DSC_EVENT_VALIDATION_FAILED_FCO_MODE_RECIPIENT, ((ADObjectId)propertyBag[ADObjectSchema.Id]).ToString(), new object[]
                    {
                        ((ADObjectId)propertyBag[ADObjectSchema.Id]).ToDNString()
                    });
                    throw new DataValidationException(error);
                }
                adobject = new ADMicrosoftExchangeRecipient();
            }
            adobject.m_Session   = recipientSession;
            adobject.propertyBag = propertyBag;
            adobject.Initialize();
            adobject.ResetChangeTracking(true);
            if (recipientSession != null)
            {
                adobject.SetIsReadOnly(recipientSession.ReadOnly);
            }
            ExTraceGlobals.ADReadDetailsTracer.TraceDebug <string, RecipientType>((long)((recipientSession != null) ? recipientSession.GetHashCode() : 0), "ADRecipientObjectSession::CreateObject - Got {0} as {1}", adobject.DistinguishedName, (RecipientType)adobject[ADRecipientSchema.RecipientType]);
            return(adobject);
        }