Ejemplo n.º 1
0
 internal DelegateLogonUser(IADOrgPerson adOrgPerson)
 {
     this.adOrgPerson = adOrgPerson;
 }
Ejemplo n.º 2
0
        internal static object[][] GetManagementChainView(IRecipientSession adSession, IADOrgPerson person, bool getPeers, params PropertyDefinition[] returnProperties)
        {
            if (returnProperties == null)
            {
                throw new ArgumentNullException("returnProperties");
            }
            int?num = null;

            for (int i = 0; i < returnProperties.Length; i++)
            {
                if (returnProperties[i] == ADOrgPersonSchema.ViewDepth)
                {
                    num = new int?(i);
                    break;
                }
            }
            PropertyDefinition[] array = new PropertyDefinition[returnProperties.Length + 1];
            returnProperties.CopyTo(array, 1);
            array[0] = ADOrgPersonSchema.Manager;
            Collection <IADRecipient[]> collection  = new Collection <IADRecipient[]>();
            Collection <Guid>           collection2 = new Collection <Guid>();
            int num2 = 0;

            if (getPeers)
            {
                ADObjectId adobjectId = person.Manager;
                while (adobjectId != null && num2 < 100)
                {
                    if (collection2.Contains(adobjectId.ObjectGuid))
                    {
                        break;
                    }
                    QueryFilter    filter = new ComparisonFilter(ComparisonOperator.Equal, ADOrgPersonSchema.Manager, adobjectId);
                    IADRecipient[] item   = adSession.Find(adSession.SearchRoot, QueryScope.SubTree, filter, null, 0);
                    collection2.Add(adobjectId.ObjectGuid);
                    collection.Add(item);
                    IADOrgPerson iadorgPerson = adSession.Read(adobjectId) as IADOrgPerson;
                    if (iadorgPerson == null)
                    {
                        adobjectId = null;
                    }
                    else if (iadorgPerson.Manager == null || iadorgPerson.Manager.ObjectGuid == adobjectId.ObjectGuid)
                    {
                        item = new IADRecipient[]
                        {
                            iadorgPerson
                        };
                        collection.Add(item);
                        num2++;
                        adobjectId = null;
                    }
                    else
                    {
                        adobjectId = iadorgPerson.Manager;
                    }
                    num2++;
                }
            }
            else
            {
                ADObjectId adobjectId = person.Id;
                while (adobjectId != null && num2 < 100 && !collection2.Contains(adobjectId.ObjectGuid))
                {
                    new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Id, adobjectId);
                    IADOrgPerson iadorgPerson2 = adSession.Read(adobjectId) as IADOrgPerson;
                    collection2.Add(adobjectId.ObjectGuid);
                    if (iadorgPerson2 == null)
                    {
                        adobjectId = null;
                    }
                    else
                    {
                        collection.Add(new IADRecipient[]
                        {
                            iadorgPerson2
                        });
                        if (iadorgPerson2.Manager != null && iadorgPerson2.Manager.ObjectGuid == adobjectId.ObjectGuid)
                        {
                            adobjectId = null;
                        }
                        else
                        {
                            adobjectId = iadorgPerson2.Manager;
                        }
                        num2++;
                    }
                }
            }
            int count = collection.Count;
            int num3  = 0;

            for (int j = 0; j < count; j++)
            {
                num3 += collection[j].Length;
            }
            object[][] array2 = new object[num3][];
            int        k      = count - 1;
            int        num4   = 0;

            while (k >= 0)
            {
                for (int l = 0; l < collection[k].Length; l++)
                {
                    array2[num4] = collection[k][l].GetProperties(returnProperties);
                    if (num != null)
                    {
                        array2[num4][num.Value] = count - 1 - k;
                    }
                    num4++;
                }
                k--;
            }
            return(array2);
        }
        // Token: 0x06002F23 RID: 12067 RVA: 0x0010FD4C File Offset: 0x0010DF4C
        private RecipientWellEventHandler.ADRecipientProperties GetADRecipientProperties(ADObjectId adObjectId, string routingAddress, string routingType)
        {
            if (string.IsNullOrEmpty(routingAddress))
            {
                throw new ArgumentNullException("routingAddress");
            }
            if (string.IsNullOrEmpty(routingType))
            {
                throw new ArgumentNullException("routingType");
            }
            IRecipientSession recipientSession = Utilities.CreateADRecipientSession(Culture.GetUserCulture().LCID, true, ConsistencyMode.IgnoreInvalid, true, base.UserContext);
            ADRecipient       adrecipient      = null;

            RecipientWellEventHandler.ADRecipientProperties result = default(RecipientWellEventHandler.ADRecipientProperties);
            if (string.Equals(routingType, "EX", StringComparison.Ordinal))
            {
                try
                {
                    CustomProxyAddress proxyAddress = new CustomProxyAddress((CustomProxyAddressPrefix)ProxyAddressPrefix.LegacyDN, routingAddress, true);
                    adrecipient = recipientSession.FindByProxyAddress(proxyAddress);
                    goto IL_FB;
                }
                catch (NonUniqueRecipientException ex)
                {
                    ExTraceGlobals.CoreTracer.TraceDebug <string>((long)this.GetHashCode(), "GetADRecipientProperties: NonUniqueRecipientException was thrown by FindByProxyAddress: {0}", ex.Message);
                    throw new OwaEventHandlerException("Unable to retrieve properties.", LocalizedStrings.GetNonEncoded(-1953304495));
                }
            }
            if (string.Equals(routingType, "SMTP", StringComparison.Ordinal))
            {
                try
                {
                    SmtpProxyAddress proxyAddress2 = new SmtpProxyAddress(routingAddress, true);
                    adrecipient = recipientSession.FindByProxyAddress(proxyAddress2);
                }
                catch (NonUniqueRecipientException ex2)
                {
                    ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "GetADRecipientProperties: NonUniqueRecipientException was thrown by FindByProxyAddress: {0}", ex2.Message);
                    throw new OwaEventHandlerException("Unable to retrieve properties.", LocalizedStrings.GetNonEncoded(-1953304495));
                }
            }
IL_FB:
            if (adrecipient == null && adObjectId != null)
            {
                adrecipient = recipientSession.Read(adObjectId);
            }
            if (adrecipient == null)
            {
                throw new OwaEventHandlerException("Unable to retrieve properties.", LocalizedStrings.GetNonEncoded(-1953304495));
            }
            IADOrgPerson iadorgPerson = adrecipient as IADOrgPerson;

            if (iadorgPerson != null)
            {
                result.Office = iadorgPerson.Office;
                result.Phone  = iadorgPerson.Phone;
                if (adrecipient.Id == null)
                {
                    throw new OwaEventHandlerException("Unable to retrieve id for AD Recipient.", LocalizedStrings.GetNonEncoded(-1953304495));
                }
                result.Id = DirectoryAssistance.ToHtmlString(adrecipient.Id);
            }
            return(result);
        }
Ejemplo n.º 4
0
        internal static MailboxSession GetClonedMailboxSession(Guid mailboxGuid, CultureInfo cultureInfo, LogonType logonType, string userContextKey, ExchangePrincipal exchangePrincipal, IADOrgPerson person, ClientSecurityContext clientSecurityContext, GenericIdentity genericIdentity, bool unifiedLogon)
        {
            MailboxSession clonedMailboxSession = null;
            UserContext    userContext          = null;
            string         expectedMailboxKey   = string.Empty;

            if (!string.IsNullOrEmpty(userContextKey))
            {
                try
                {
                    OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                    {
                        UserContextManager.UserContextCacheWrapper userContextCacheWrapper = (UserContextManager.UserContextCacheWrapper)HttpRuntime.Cache.Get(userContextKey);
                        if (userContextCacheWrapper != null && userContextCacheWrapper.UserContext != null && userContextCacheWrapper.UserContext.TerminationStatus == UserContextTerminationStatus.NotTerminate)
                        {
                            userContext = (userContextCacheWrapper.UserContext as UserContext);
                            if (userContext != null && userContext.FeaturesManager != null && userContext.FeaturesManager.ServerSettings.OwaMailboxSessionCloning.Enabled && userContext.UserCulture != null && !userContext.IsExplicitLogon)
                            {
                                expectedMailboxKey   = AccessingPrincipalTiedCache.BuildKeyCacheKey(mailboxGuid, cultureInfo, logonType);
                                clonedMailboxSession = userContext.CloneMailboxSession(expectedMailboxKey, exchangePrincipal, person, clientSecurityContext, genericIdentity, unifiedLogon);
                            }
                        }
                    });
                }
                catch (GrayException ex)
                {
                    ExTraceGlobals.UserContextCallTracer.TraceError(0L, string.Format("Exception while cloning MailboxSession, MailboxKey: {0}, Exception: {1}", expectedMailboxKey, ex.Message));
                }
            }
            return(clonedMailboxSession);
        }
Ejemplo n.º 5
0
        // Token: 0x06002A99 RID: 10905 RVA: 0x000EEF08 File Offset: 0x000ED108
        internal static void RenderOrganizationContents(TextWriter writer, UserContext userContext, IADOrgPerson orgPerson, IRecipientSession adRecipientSession)
        {
            object[][] managementChainView = orgPerson.GetManagementChainView(false, new PropertyDefinition[]
            {
                ADObjectSchema.Id,
                ADRecipientSchema.DisplayName,
                ADOrgPersonSchema.Title
            });
            if (managementChainView != null)
            {
                ReadADOrgPerson.RenderManagerList(writer, userContext, managementChainView);
            }
            ADRecipient adrecipient = null;

            if (orgPerson.Manager != null)
            {
                try
                {
                    adrecipient = adRecipientSession.Read(orgPerson.Manager);
                }
                catch (NonUniqueRecipientException ex)
                {
                    ExTraceGlobals.DirectoryTracer.TraceDebug <string>(0L, "ReadADOrgPerson.RenderOrganizationContents: NonUniqueRecipientException thrown by IRecipientSession.Read: {0}", ex.Message);
                }
            }
            if (adrecipient != null)
            {
                IADOrgPerson iadorgPerson      = (IADOrgPerson)adrecipient;
                object[][]   directReportsView = iadorgPerson.GetDirectReportsView(new PropertyDefinition[]
                {
                    ADObjectSchema.Id,
                    ADRecipientSchema.DisplayName,
                    ADOrgPersonSchema.Title
                });
                if (directReportsView != null)
                {
                    ReadADOrgPerson.RenderPeersList(writer, directReportsView, orgPerson.Id, orgPerson.DisplayName, orgPerson.Title);
                }
            }
            else
            {
                ReadADOrgPerson.RenderPeopleLabelHeading(writer, LocalizedStrings.GetHtmlEncoded(1804838102));
                ReadADOrgPerson.RenderSelf(writer, orgPerson.Id, orgPerson.DisplayName, orgPerson.Title);
            }
            object[][] directReportsView2 = orgPerson.GetDirectReportsView(new PropertyDefinition[]
            {
                ADObjectSchema.Id,
                ADRecipientSchema.DisplayName,
                ADOrgPersonSchema.Title
            });
            if (directReportsView2 != null)
            {
                ReadADOrgPerson.RenderDirectReportsList(writer, directReportsView2);
            }
        }
        // Token: 0x06001B55 RID: 6997 RVA: 0x0009C3AC File Offset: 0x0009A5AC
        public static IDictionary <AddressFormatTable.AddressPart, AddressComponent> GetAddressInfo(IADOrgPerson orgPerson)
        {
            if (orgPerson == null)
            {
                throw new ArgumentNullException("orgPerson");
            }
            IDictionary <AddressFormatTable.AddressPart, AddressComponent> dictionary = new Dictionary <AddressFormatTable.AddressPart, AddressComponent>();

            AddressFormatTable.AddressPart[] cultureAddressMap = AddressFormatTable.GetCultureAddressMap(Culture.GetUserCulture().LCID);
            foreach (AddressFormatTable.AddressPart addressPart in cultureAddressMap)
            {
                PropertyDefinition property = AddressFormatTable.LookupAddressPropertyAd(addressPart);
                string             adorgPersonStringPropertyValue = ContactUtilities.GetADOrgPersonStringPropertyValue(orgPerson, property);
                if (!string.IsNullOrEmpty(adorgPersonStringPropertyValue))
                {
                    AddressComponent value = ContactUtilities.ProcessAddressPartInternal(adorgPersonStringPropertyValue, addressPart);
                    dictionary[addressPart] = value;
                }
            }
            return(dictionary);
        }
Ejemplo n.º 7
0
        public MailboxSession CloneMailboxSession(string mailboxKey, ExchangePrincipal exchangePrincipal, IADOrgPerson person, ClientSecurityContext clientSecurityContext, GenericIdentity genericIdentity, bool unifiedLogon)
        {
            MailboxSession result = null;

            if (!string.IsNullOrEmpty(mailboxKey) && !base.IsDisposed && this.mailboxSession != null)
            {
                string text = AccessingPrincipalTiedCache.BuildKeyCacheKey(this.clonedMailboxProperties.MailboxGuid, this.clonedMailboxProperties.MailboxCulture, this.clonedMailboxProperties.LogonType);
                if (mailboxKey.Equals(text, StringComparison.InvariantCulture))
                {
                    if (this.ExchangePrincipal != null && object.Equals(this.ExchangePrincipal.ObjectId, exchangePrincipal.ObjectId))
                    {
                        result = this.mailboxSession.CloneWithBestAccess(exchangePrincipal, person, clientSecurityContext, this.clonedMailboxProperties.ClientInfoString, genericIdentity, unifiedLogon);
                    }
                    else
                    {
                        ExTraceGlobals.UserContextCallTracer.TraceWarning(0L, string.Format("CloneMailboxSession: Mailbox owner not same, mailboxkey:{0}", text));
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 8
0
 private void Initialize(ClientSecurityContext context, AuthzContextHandle handle, ClientIdentityInfo clientIdentityInfo, string userDn, IADOrgPerson adEntry, GenericIdentity auxiliaryIdentity)
 {
     this.context            = context;
     this.authzContextHandle = handle;
     this.clientIdentityInfo = clientIdentityInfo;
     this.userDn             = userDn;
     this.adEntry            = adEntry;
     this.auxiliaryIdentity  = auxiliaryIdentity;
 }
        private static NewExchangeNotification.LookupResult LookupSmtpAddressAndLanguage(IRecipientSession recipientSession, RecipientIdParameter recipientIdParameter)
        {
            IEnumerable <ADRecipient> objects = recipientIdParameter.GetObjects <ADRecipient>(null, recipientSession);
            ADRecipient adrecipient           = null;

            using (IEnumerator <ADRecipient> enumerator = objects.GetEnumerator())
            {
                if (!enumerator.MoveNext())
                {
                    if (SmtpAddress.IsValidSmtpAddress(recipientIdParameter.RawIdentity))
                    {
                        return(new NewExchangeNotification.LookupResult
                        {
                            Success = true,
                            SmtpAddress = SmtpAddress.Parse(recipientIdParameter.RawIdentity),
                            Languages = new CultureInfo[0]
                        });
                    }
                    return(new NewExchangeNotification.LookupResult
                    {
                        Success = false,
                        ErrorMessage = Strings.NoRecipientsForRecipientId(recipientIdParameter.ToString())
                    });
                }
                else
                {
                    adrecipient = enumerator.Current;
                    if (enumerator.MoveNext())
                    {
                        return(new NewExchangeNotification.LookupResult
                        {
                            Success = false,
                            ErrorMessage = Strings.MoreThanOneRecipientForRecipientId(recipientIdParameter.ToString())
                        });
                    }
                }
            }
            if (SmtpAddress.Empty.Equals(adrecipient.PrimarySmtpAddress))
            {
                return(new NewExchangeNotification.LookupResult
                {
                    Success = false,
                    ErrorMessage = Strings.NoSmtpAddressForRecipientId(recipientIdParameter.ToString())
                });
            }
            IADOrgPerson iadorgPerson = adrecipient as IADOrgPerson;

            if (iadorgPerson == null)
            {
                return(new NewExchangeNotification.LookupResult
                {
                    Success = true,
                    SmtpAddress = adrecipient.PrimarySmtpAddress,
                    Languages = new CultureInfo[0]
                });
            }
            return(new NewExchangeNotification.LookupResult
            {
                Success = true,
                SmtpAddress = adrecipient.PrimarySmtpAddress,
                Languages = iadorgPerson.Languages
            });
        }
Ejemplo n.º 10
0
 private void Initialize(WindowsPrincipal principal, ClientSecurityContext context, AuthzContextHandle handle, ClientIdentityInfo clientIdentityInfo, string userDn, IADOrgPerson adEntry, GenericIdentity auxiliaryIdentity)
 {
     this.principal = principal;
     this.Initialize(context, handle, clientIdentityInfo, userDn, adEntry, auxiliaryIdentity);
 }
Ejemplo n.º 11
0
 public MailboxAccessInfo(IADOrgPerson accessingUserAdEntry, ClientIdentityInfo clientIdentityInfo)
 {
     Util.ThrowOnNullArgument(accessingUserAdEntry, "accessingUserAdEntry");
     Util.ThrowOnNullArgument(clientIdentityInfo, "clientIdentityInfo");
     this.Initialize(null, null, null, clientIdentityInfo, null, accessingUserAdEntry, null);
 }
Ejemplo n.º 12
0
 public MailboxAccessInfo(IADOrgPerson accessingUserAdEntry, AuthzContextHandle authenticatedUserHandle)
 {
     Util.ThrowOnNullArgument(accessingUserAdEntry, "accessingUserAdEntry");
     Util.ThrowOnNullArgument(authenticatedUserHandle, "authenticatedUserHandle");
     this.Initialize(null, null, authenticatedUserHandle, null, null, accessingUserAdEntry, null);
 }
Ejemplo n.º 13
0
 public MailboxAccessInfo(IADOrgPerson accessingUserAdEntry, ClientSecurityContext authenticatedUserContext)
 {
     Util.ThrowOnNullArgument(accessingUserAdEntry, "accessingUserAdEntry");
     Util.ThrowOnNullArgument(authenticatedUserContext, "authenticatedUserContext");
     this.Initialize(null, authenticatedUserContext, null, null, null, accessingUserAdEntry, null);
 }
Ejemplo n.º 14
0
 public MailboxAccessInfo(IADOrgPerson accessingUserAdEntry, WindowsPrincipal authenticatedUserPrincipal)
 {
     Util.ThrowOnNullArgument(accessingUserAdEntry, "accessingUserAdEntry");
     Util.ThrowOnNullArgument(authenticatedUserPrincipal, "authenticatedUserPrincipal");
     this.Initialize(authenticatedUserPrincipal, null, null, null, null, accessingUserAdEntry, null);
 }