コード例 #1
0
        // Token: 0x06000310 RID: 784 RVA: 0x000132E8 File Offset: 0x000114E8
        private static RfriContext CreateRfriContext(ClientBinding clientBinding)
        {
            RfriContext rfriContext = null;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                ClientSecurityContext clientSecurityContext = null;
                bool   isAnonymous = false;
                string text        = null;
                string userDomain  = null;
                RpcHttpConnectionProperties rpcHttpConnectionProperties = null;
                if (!RpcDispatch.TryGetAuthContextInfo(clientBinding, out clientSecurityContext, out isAnonymous, out text, out userDomain, out rpcHttpConnectionProperties))
                {
                    ExTraceGlobals.ReferralTracer.TraceError <Guid>(0L, "Could not resolve anonymous user for session id: {0}", clientBinding.AssociationGuid);
                    throw new RfriException(RfriStatus.LogonFailed, "Could not resolve anonymous user.");
                }
                disposeGuard.Add <ClientSecurityContext>(clientSecurityContext);
                Guid empty = Guid.Empty;
                if (rpcHttpConnectionProperties != null && rpcHttpConnectionProperties.RequestIds.Length > 0)
                {
                    Guid.TryParse(rpcHttpConnectionProperties.RequestIds[rpcHttpConnectionProperties.RequestIds.Length - 1], out empty);
                }
                rfriContext = new RfriContext(clientSecurityContext, userDomain, clientBinding.ClientAddress, clientBinding.ServerAddress, clientBinding.ProtocolSequence, clientBinding.AuthenticationType.ToString(), clientBinding.IsEncrypted, isAnonymous, empty);
                disposeGuard.Add <RfriContext>(rfriContext);
                if (!rfriContext.TryAcquireBudget())
                {
                    ExTraceGlobals.ReferralTracer.TraceError((long)rfriContext.ContextHandle, "Could not acquire budget");
                    throw new RfriException(RfriStatus.GeneralFailure, "Failed to acquire budget.");
                }
                disposeGuard.Success();
            }
            return(rfriContext);
        }
コード例 #2
0
        // Token: 0x06000313 RID: 787 RVA: 0x0001366C File Offset: 0x0001186C
        private ICancelableAsyncResult BeginWrapper(string methodName, CancelableAsyncCallback asyncCallback, object asyncState, ClientBinding clientBinding, string legacyDn, Func <RfriContext, RfriDispatchTask> beginDelegate)
        {
            ICancelableAsyncResult asyncResult = null;

            RfriAsyncDispatch.ConditionalExceptionWrapper(ExTraceGlobals.ReferralTracer.IsTraceEnabled(TraceType.DebugTrace), delegate
            {
                if (ExTraceGlobals.ReferralTracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    using (ClientSecurityContext clientSecurityContext = clientBinding.GetClientSecurityContext())
                    {
                        ExTraceGlobals.ReferralTracer.TraceDebug(0, 0L, "{0} started. LegacyDn={1}. ClientAddress={2}. ServerAddress={3}. ProtocolSequence={4}. EndPoint={5}. IsEncrypted={6}. ClientSecurityContext={7}.", new object[]
                        {
                            methodName,
                            legacyDn,
                            clientBinding.ClientAddress,
                            clientBinding.ServerAddress,
                            clientBinding.ProtocolSequence,
                            clientBinding.ClientEndpoint,
                            clientBinding.IsEncrypted,
                            clientSecurityContext
                        });
                    }
                }
                FailureAsyncResult <RfriStatus> failureAsyncResult = null;
                this.CheckShuttingDown();
                try
                {
                    using (DisposeGuard disposeGuard = default(DisposeGuard))
                    {
                        RfriContext rfriContext = RfriAsyncDispatch.CreateRfriContext(clientBinding);
                        disposeGuard.Add <RfriContext>(rfriContext);
                        RfriDispatchTask rfriDispatchTask = beginDelegate(rfriContext);
                        disposeGuard.Add <RfriDispatchTask>(rfriDispatchTask);
                        asyncResult = rfriDispatchTask.AsyncResult;
                        this.SubmitTask(rfriDispatchTask);
                        disposeGuard.Success();
                    }
                }
                catch (FailRpcException ex)
                {
                    failureAsyncResult = new FailureAsyncResult <RfriStatus>((RfriStatus)ex.ErrorCode, IntPtr.Zero, ex, asyncCallback, asyncState);
                    asyncResult        = failureAsyncResult;
                }
                catch (RfriException ex2)
                {
                    failureAsyncResult = new FailureAsyncResult <RfriStatus>(ex2.Status, IntPtr.Zero, ex2, asyncCallback, asyncState);
                    asyncResult        = failureAsyncResult;
                }
                if (failureAsyncResult != null && !ThreadPool.QueueUserWorkItem(RfriAsyncDispatch.FailureWaitCallback, failureAsyncResult))
                {
                    failureAsyncResult.InvokeCallback();
                }
                ExTraceGlobals.ReferralTracer.TraceDebug <string>(0, 0L, "{0} succeeded.", methodName);
            }, delegate(Exception exception)
            {
                ExTraceGlobals.ReferralTracer.TraceDebug <string, Exception>(0, 0L, "{0} failed. Exception={1}.", methodName, exception);
            });
            return(asyncResult);
        }
コード例 #3
0
ファイル: RfriContext.cs プロジェクト: YHZX2013/exchange_diff
        internal RfriStatus GetFQDNFromLegacyDN(string legacyDN, out string serverFQDN)
        {
            RfriStatus rfriStatus = RfriStatus.Success;

            serverFQDN = null;
            RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "Requested DN: {0}", RfriContext.GetString(legacyDN));
            if (legacyDN.Contains("@"))
            {
                LegacyDN legacyDN2;
                if (LegacyDN.TryParse(legacyDN, out legacyDN2))
                {
                    string text;
                    legacyDN2.GetParentLegacyDN(out text, out serverFQDN);
                    if (string.IsNullOrEmpty(serverFQDN) || !serverFQDN.Contains("@"))
                    {
                        rfriStatus = RfriStatus.NoSuchObject;
                    }
                }
                else
                {
                    rfriStatus = RfriStatus.NoSuchObject;
                }
            }
            else
            {
                legacyDN   = ExchangeRpcClientAccess.FixFakeRedirectLegacyDNIfNeeded(legacyDN);
                rfriStatus = ServerFqdnCache.LookupFQDNByLegacyDN(legacyDN, out serverFQDN);
            }
            if (rfriStatus != RfriStatus.Success || string.IsNullOrEmpty(serverFQDN))
            {
                if (rfriStatus == RfriStatus.Success)
                {
                    rfriStatus = RfriStatus.NoSuchObject;
                }
                this.ProtocolLogSession[ProtocolLog.Field.Failures] = RfriContext.GetString(legacyDN);
            }
            else
            {
                RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "Referring to {0}", serverFQDN);
            }
            return(rfriStatus);
        }
コード例 #4
0
ファイル: RfriContext.cs プロジェクト: YHZX2013/exchange_diff
        internal RfriStatus GetNewDSA(string userDN, out string serverFQDN)
        {
            serverFQDN = null;
            RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "Requested user DN: {0}", RfriContext.GetString(userDN));
            string     str;
            RfriStatus rfriStatus;

            if (this.IsUsingHttp())
            {
                str = userDN;
                if (!this.TryGetPersonalizedServer(userDN, out serverFQDN))
                {
                    rfriStatus = ServerFqdnCache.LookupFQDNByLegacyDN(null, out serverFQDN);
                    RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "ServerFqdnCache.LookupFQDNByLegacyDN(null): {0}", serverFQDN ?? "(null)");
                }
                else
                {
                    rfriStatus = RfriStatus.Success;
                }
            }
            else
            {
                string clientAccessServerLegacyDN = this.GetClientAccessServerLegacyDN(userDN);
                RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "RfriContext.GetClientAccessServerLegacyDN: {0}", clientAccessServerLegacyDN ?? "(null)");
                str        = clientAccessServerLegacyDN;
                rfriStatus = ServerFqdnCache.LookupFQDNByLegacyDN(clientAccessServerLegacyDN, out serverFQDN);
                RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "ServerFqdnCache.LookupFQDNByLegacyDN: {0}", serverFQDN ?? "(null)");
            }
            if (rfriStatus != RfriStatus.Success || string.IsNullOrEmpty(serverFQDN))
            {
                if (rfriStatus == RfriStatus.Success)
                {
                    rfriStatus = RfriStatus.NoSuchObject;
                }
                this.ProtocolLogSession[ProtocolLog.Field.Failures] = RfriContext.GetString(str);
            }
            else
            {
                RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "Referring to {0}", serverFQDN);
            }
            return(rfriStatus);
        }
コード例 #5
0
 public RfriGetFQDNFromLegacyDNDispatchTask(CancelableAsyncCallback asyncCallback, object asyncState, ProtocolRequestInfo protocolRequestInfo, ClientBinding clientBinding, RfriContext context, RfriGetFQDNFromLegacyDNFlags flags, string serverDn) : base(asyncCallback, asyncState, protocolRequestInfo, clientBinding, context)
 {
     this.flags    = flags;
     this.serverDn = serverDn;
 }
コード例 #6
0
 public RfriGetMailboxUrlDispatchTask(CancelableAsyncCallback asyncCallback, object asyncState, ProtocolRequestInfo protocolRequestInfo, ClientBinding clientBinding, RfriContext context, RfriGetMailboxUrlFlags flags, string hostname, string serverDn) : base(asyncCallback, asyncState, protocolRequestInfo, clientBinding, context)
 {
     this.flags    = flags;
     this.hostname = hostname;
     this.serverDn = serverDn;
 }
コード例 #7
0
 public RfriGetNewDSADispatchTask(CancelableAsyncCallback asyncCallback, object asyncState, ProtocolRequestInfo protocolRequestInfo, ClientBinding clientBinding, RfriContext context, RfriGetNewDSAFlags flags, string userDn) : base(asyncCallback, asyncState, protocolRequestInfo, clientBinding, context)
 {
     this.flags  = flags;
     this.userDn = userDn;
 }
コード例 #8
0
ファイル: RfriContext.cs プロジェクト: YHZX2013/exchange_diff
        private bool TryGetPersonalizedServer(string userLegacyDN, out string personalizedServer)
        {
            personalizedServer = string.Empty;
            bool          flag = true;
            NspiPrincipal nspiPrincipal;

            if (string.IsNullOrEmpty(userLegacyDN) || LegacyDN.StringComparer.Equals(userLegacyDN, this.LegacyDistinguishedName))
            {
                this.protocolLogSession[ProtocolLog.Field.OperationSpecific] = "Self";
                nspiPrincipal = this.nspiPrincipal;
            }
            else
            {
                this.protocolLogSession[ProtocolLog.Field.OperationSpecific] = "Other";
                nspiPrincipal = this.NspiPrincipalFromLegacyDN(userLegacyDN);
                flag          = false;
                if (nspiPrincipal == null)
                {
                    return(false);
                }
            }
            if (!flag && nspiPrincipal.ExchangeVersion != null && nspiPrincipal.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2012))
            {
                string clientAccessServerLegacyDN = this.GetClientAccessServerLegacyDN(userLegacyDN);
                RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "RfriContext.GetClientAccessServerLegacyDN: {0}", RfriContext.GetString(clientAccessServerLegacyDN));
                ServerFqdnCache.LookupFQDNByLegacyDN(clientAccessServerLegacyDN, out personalizedServer);
                RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "ServerFqdnCache.LookupFQDNByLegacyDN: {0}", RfriContext.GetString(personalizedServer));
                return(true);
            }
            SmtpAddress primarySmtpAddress = nspiPrincipal.PrimarySmtpAddress;

            if (nspiPrincipal.ExchangeGuid != Guid.Empty)
            {
                personalizedServer = ExchangeRpcClientAccess.CreatePersonalizedServer(nspiPrincipal.ExchangeGuid, nspiPrincipal.PrimarySmtpAddress.Domain);
                RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "RfriContext.GetPersonalizedServer: {0}", RfriContext.GetString(personalizedServer));
                return(true);
            }
            return(false);
        }
コード例 #9
0
 // Token: 0x0600011F RID: 287 RVA: 0x0000616D File Offset: 0x0000436D
 public RfriDispatchTask(CancelableAsyncCallback asyncCallback, object asyncState, ProtocolRequestInfo protocolRequestInfo, ClientBinding clientBinding, RfriContext context) : base(asyncCallback, asyncState)
 {
     this.status = RfriStatus.GeneralFailure;
     this.protocolRequestInfo = protocolRequestInfo;
     this.clientBinding       = clientBinding;
     this.context             = context;
 }