Example #1
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));
        }
Example #2
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);
 }