Exemplo n.º 1
0
 // Token: 0x060002FC RID: 764 RVA: 0x0000FB98 File Offset: 0x0000DD98
 void IAirSyncUser.InitializeADUser()
 {
     if (this.activeDirectoryUser == null)
     {
         this.activeDirectoryUser = ADUserCache.TryGetADUser(this, this.context.ProtocolLogger);
         if (this.activeDirectoryUser != null)
         {
             this.deviceBehaviorCacheGuid = this.activeDirectoryUser.OriginalId.ObjectGuid;
             this.Features = EasFeaturesManager.Create(this.activeDirectoryUser, this.context.FlightingOverrides);
         }
     }
 }
Exemplo n.º 2
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);
        }