// Token: 0x06001AAD RID: 6829 RVA: 0x000647F4 File Offset: 0x000629F4
        private bool IsSelfPhotoRequest()
        {
            if (base.CallContext.AccessingPrincipal == null)
            {
                return(false);
            }
            if (base.CallContext.AccessingPrincipal.ObjectId.Equals(this.adObjectId))
            {
                this.tracer.TraceDebug((long)this.GetHashCode(), "Requestor is requesting his/her own photo: target AD object ID matches requestor's.");
                return(true);
            }
            PhotoPrincipal photoPrincipal = new PhotoPrincipal
            {
                EmailAddresses = base.CallContext.AccessingPrincipal.GetAllEmailAddresses()
            };
            PhotoPrincipal other = new PhotoPrincipal
            {
                EmailAddresses = new string[]
                {
                    this.email
                }
            };
            bool flag = photoPrincipal.IsSame(other);

            if (flag)
            {
                this.tracer.TraceDebug((long)this.GetHashCode(), "Requestor is requesting his/her own photo: target and requestor are same principal.");
            }
            return(flag);
        }
Exemplo n.º 2
0
        private bool VerifyUserPermissions(string userEmail, OrganizationId userOrganizationId, string targetUserEmailAddress)
        {
            bool result;

            try
            {
                if (!SmtpAddress.IsValidSmtpAddress(targetUserEmailAddress))
                {
                    result = false;
                }
                else
                {
                    PhotoPrincipal requestor = new PhotoPrincipal
                    {
                        EmailAddresses = new List <string>
                        {
                            userEmail
                        },
                        OrganizationId = userOrganizationId
                    };
                    PhotoPrincipal target = new PhotoPrincipal
                    {
                        EmailAddresses = new List <string>
                        {
                            targetUserEmailAddress
                        },
                        OrganizationId = userOrganizationId
                    };
                    new PhotoAuthorization(OrganizationIdCache.Singleton, ExTraceGlobals.ProtocolTracer).Authorize(requestor, target);
                    AirSyncDiagnostics.TraceDebug <string, string>(ExTraceGlobals.ProtocolTracer, null, "AirSyncPhotoRetriever::VerifyUserPermissions - {0} has permissiosn to retrieve photos for user {2}.", userEmail, targetUserEmailAddress);
                    result = true;
                }
            }
            catch (AccessDeniedException arg)
            {
                AirSyncDiagnostics.TraceError <AccessDeniedException, string>(ExTraceGlobals.ProtocolTracer, "Access denied verifying user's permissions to retrieve thumbnailPhoto via GetUserPhoto for {0}.  Exception: {1}. Current user :{2}", targetUserEmailAddress, arg, userEmail);
                result = false;
            }
            return(result);
        }