Ejemplo n.º 1
0
        internal NspiPrincipal NspiPrincipalFromLegacyDN(string legacyDN)
        {
            ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(this.nspiPrincipal.OrganizationId);
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, this.nspiPrincipal.DirectorySearchRoot, CultureInfo.CurrentCulture.LCID, true, ConsistencyMode.IgnoreInvalid, null, sessionSettings, 584, "NspiPrincipalFromLegacyDN", "f:\\15.00.1497\\sources\\dev\\DoMT\\src\\Service\\RfriContext.cs");

            tenantOrRootOrgRecipientSession.ServerTimeout = Configuration.ADTimeout;
            try
            {
                ADUser aduser = tenantOrRootOrgRecipientSession.FindByLegacyExchangeDN(legacyDN) as ADUser;
                if (aduser != null && !(bool)aduser[ADRecipientSchema.HiddenFromAddressListsValue])
                {
                    return(NspiPrincipal.FromADUser(aduser));
                }
            }
            catch (NonUniqueRecipientException)
            {
                RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "NonUniqueRecipientException thrown for {0}", legacyDN);
            }
            catch (ObjectNotFoundException)
            {
                RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "ObjectNotFoundException thrown: Couldn't find requested user  for {0}", legacyDN);
            }
            catch (MailboxInfoStaleException)
            {
                RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "MailboxInfoStaleException thrown for {0}", legacyDN);
            }
            catch (CannotGetSiteInfoException)
            {
                RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "CannotGetSiteInfoException thrown for {0}", legacyDN);
            }
            return(null);
        }
Ejemplo n.º 2
0
        public static NspiPrincipal FromUserSid(SecurityIdentifier sid, string userDomain)
        {
            NspiPrincipal principal = null;

            if (!string.IsNullOrEmpty(userDomain))
            {
                MiniRecipient miniRecipient = NspiPrincipal.FindMiniRecipientBySid(ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(userDomain), sid);
                if (miniRecipient != null)
                {
                    principal = new NspiPrincipal(miniRecipient);
                }
            }
            else if (Configuration.IsDatacenter)
            {
                ExTraceGlobals.NspiTracer.TraceWarning <SecurityIdentifier>(0L, "We have to do a fan out query for user {0} because of legacy client.", sid);
                DirectoryHelper.DoAdCallAndTranslateExceptions(delegate
                {
                    MiniRecipient miniRecipientFromUserId = PartitionDataAggregator.GetMiniRecipientFromUserId(sid);
                    if (miniRecipientFromUserId != null)
                    {
                        principal = new NspiPrincipal(miniRecipientFromUserId);
                    }
                }, "ADAccountPartitionLocator::GetAllAccountPartitionIds");
            }
            else
            {
                principal = NspiPrincipal.FromUserSid(ADSessionSettings.FromRootOrgScopeSet(), sid);
            }
            return(principal ?? new NspiPrincipal(sid));
        }
Ejemplo n.º 3
0
        public static NspiPrincipal FromUserSid(ADSessionSettings sessionSettings, SecurityIdentifier sid)
        {
            MiniRecipient miniRecipient = NspiPrincipal.FindMiniRecipientBySid(sessionSettings, sid);

            if (miniRecipient != null)
            {
                return(new NspiPrincipal(miniRecipient));
            }
            return(new NspiPrincipal(sid));
        }
Ejemplo n.º 4
0
 internal RfriStatus Initialize()
 {
     if (this.clientSecurityContext == null)
     {
         return(RfriStatus.LogonFailed);
     }
     try
     {
         this.nspiPrincipal = NspiPrincipal.FromUserSid(this.clientSecurityContext.UserSid, this.userDomain);
         if (this.nspiPrincipal.OrganizationId != null && this.nspiPrincipal.OrganizationId.OrganizationalUnit != null)
         {
             this.protocolLogSession[ProtocolLog.Field.OrganizationInfo] = this.nspiPrincipal.OrganizationId.OrganizationalUnit.ToCanonicalName();
         }
     }
     catch (NonUniqueRecipientException)
     {
     }
     catch (ObjectNotFoundException)
     {
     }
     catch (MailboxInfoStaleException)
     {
     }
     catch (CannotGetSiteInfoException)
     {
     }
     this.protocolLogSession[ProtocolLog.Field.ClientName] = this.LegacyDistinguishedName;
     if (ExUserTracingAdaptor.Instance.IsTracingEnabledUser(this.LegacyDistinguishedName))
     {
         BaseTrace.CurrentThreadSettings.EnableTracing();
     }
     RfriContext.ReferralTracer.TraceDebug <string, SecurityIdentifier>((long)this.ContextHandle, "User {0}, Sid: {1}", this.LegacyDistinguishedName, this.clientSecurityContext.UserSid);
     if (!this.isAnonymous && Configuration.EncryptionRequired && !this.encrypted)
     {
         RfriContext.ReferralTracer.TraceError((long)this.ContextHandle, "Encrypted connection is required.");
         this.ProtocolLogSession[ProtocolLog.Field.Failures] = "EncryptionRequired";
         return(RfriStatus.GeneralFailure);
     }
     return(RfriStatus.Success);
 }