public static SharingPolicy ReadSharingPolicy(Guid mailboxGuid, bool isArchive, IRecipientSession recipientSession)
        {
            ADRecipient adrecipient = DirectoryHelper.ReadADRecipient(mailboxGuid, isArchive, recipientSession);

            if (adrecipient == null)
            {
                throw new ObjectNotFoundException(ServerStrings.ADUserNotFound);
            }
            ADUser aduser = adrecipient as ADUser;

            if (aduser == null)
            {
                ExTraceGlobals.StorageTracer.TraceError <ADRecipient>((long)mailboxGuid.GetHashCode(), "ExchangePrincipal::ReadSharingPolicy. This is not an ADUser so policy doesn't apply. Recipient = {0}.", adrecipient);
                return(null);
            }
            ADObjectId        adobjectId = aduser.SharingPolicy;
            ADSessionSettings adsessionSettings;

            if (SharedConfiguration.IsDehydratedConfiguration(aduser.OrganizationId))
            {
                SharedConfiguration sharedConfiguration = SharedConfiguration.GetSharedConfiguration(aduser.OrganizationId);
                adsessionSettings = sharedConfiguration.GetSharedConfigurationSessionSettings();
            }
            else
            {
                adsessionSettings = aduser.OrganizationId.ToADSessionSettings();
                adsessionSettings.IsSharedConfigChecked = true;
            }
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, adsessionSettings, 248, "ReadSharingPolicy", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\DirectoryHelper.cs");

            if (adobjectId == null)
            {
                FederatedOrganizationId federatedOrganizationId = tenantOrTopologyConfigurationSession.GetFederatedOrganizationId(tenantOrTopologyConfigurationSession.SessionSettings.CurrentOrganizationId);
                if (federatedOrganizationId != null)
                {
                    adobjectId = federatedOrganizationId.DefaultSharingPolicyLink;
                }
            }
            SharingPolicy sharingPolicy = null;

            if (adobjectId != null)
            {
                sharingPolicy = tenantOrTopologyConfigurationSession.Read <SharingPolicy>(adobjectId);
                if (sharingPolicy == null)
                {
                    throw new ObjectNotFoundException(ServerStrings.SharingPolicyNotFound(adobjectId.Name));
                }
            }
            return(sharingPolicy);
        }
Exemple #2
0
        private IConfigurationSession GenerateIConfigurationSessionForShareableObjects(OrganizationId organizationId, SharedConfiguration sharedConfig)
        {
            ADSessionSettings adsessionSettings = null;

            if (sharedConfig != null)
            {
                adsessionSettings = sharedConfig.GetSharedConfigurationSessionSettings();
            }
            if (adsessionSettings == null)
            {
                adsessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, organizationId, base.ExecutingUserOrganizationId, false);
                adsessionSettings.IsSharedConfigChecked = true;
            }
            return(DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, base.NetCredential, adsessionSettings, 720, "GenerateIConfigurationSessionForShareableObjects", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Common\\recipient\\GetRecipientBase.cs"));
        }
        private IList <TeamMailboxProvisioningPolicy> GetTeamMailboxPolicies()
        {
            OrganizationId        currentOrganizationId = base.CurrentOrganizationId;
            IConfigurationSession session = this.ConfigurationSession;

            if (SharedConfiguration.IsDehydratedConfiguration(currentOrganizationId) || (SharedConfiguration.GetSharedConfigurationState(currentOrganizationId) & SharedTenantConfigurationState.Static) != SharedTenantConfigurationState.UnSupported)
            {
                ADSessionSettings   adsessionSettings   = null;
                SharedConfiguration sharedConfiguration = SharedConfiguration.GetSharedConfiguration(currentOrganizationId);
                if (sharedConfiguration != null)
                {
                    adsessionSettings = sharedConfiguration.GetSharedConfigurationSessionSettings();
                }
                if (adsessionSettings == null)
                {
                    adsessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, currentOrganizationId, base.ExecutingUserOrganizationId, false);
                    adsessionSettings.IsSharedConfigChecked = true;
                }
                session = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, base.NetCredential, adsessionSettings, 732, "GetTeamMailboxPolicies", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\TeamMailbox\\NewSiteMailbox.cs");
            }
            return(DefaultTeamMailboxProvisioningPolicyUtility.GetDefaultPolicies(session));
        }
Exemple #4
0
		private void CheckResourceProperties()
		{
			if (this.DataObject.IsChanged(ADRecipientSchema.ResourceSearchProperties) || this.DataObject.IsChanged(ADRecipientSchema.ResourceMetaData) || this.DataObject.IsChanged(ADRecipientSchema.ResourcePropertiesDisplay))
			{
				SharedConfiguration sharedConfiguration = SharedConfiguration.GetSharedConfiguration(base.CurrentOrganizationId);
				IConfigurationSession configurationSession = this.ConfigurationSession;
				if (sharedConfiguration != null)
				{
					configurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(this.ConfigurationSession.ConsistencyMode, sharedConfiguration.GetSharedConfigurationSessionSettings(), 4180, "CheckResourceProperties", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\mailbox\\SetMailbox.cs");
				}
				configurationSession.SessionSettings.IsSharedConfigChecked = true;
				configurationSession.SessionSettings.IsRedirectedToSharedConfig = false;
				ResourceBookingConfig resourceBookingConfig = configurationSession.Read<ResourceBookingConfig>(ResourceBookingConfig.GetWellKnownLocation(configurationSession.GetOrgContainerId()));
				List<string> list = new List<string>(this.DataObject.ResourceCustom);
				list.Remove(this.DataObject.ResourceType.Value.ToString());
				foreach (string text in list)
				{
					if (!resourceBookingConfig.IsPropAllowedOnResourceType(this.DataObject.ResourceType.Value.ToString(), text))
					{
						this.WriteError(new RecipientTaskException(Strings.ErrorResourceSearchPropertyInvalid(text)), ExchangeErrorCategory.Client, this.DataObject, false);
					}
				}
			}
		}
Exemple #5
0
        protected override void WriteResult(IConfigurable dataObject)
        {
            RoleAssignmentPolicy roleAssignmentPolicy = (RoleAssignmentPolicy)dataObject;

            Result <ExchangeRoleAssignment>[] roleAssignmentResults;
            if (base.SharedConfiguration != null)
            {
                SharedConfiguration   sharedConfiguration = base.SharedConfiguration;
                IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(true, ConsistencyMode.PartiallyConsistent, sharedConfiguration.GetSharedConfigurationSessionSettings(), 553, "WriteResult", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\MailboxPolicies\\RoleAssignmentPolicyTasks.cs");
                roleAssignmentResults = tenantOrTopologyConfigurationSession.FindRoleAssignmentsByUserIds(new ADObjectId[]
                {
                    sharedConfiguration.GetSharedRoleAssignmentPolicy()
                }, false);
                roleAssignmentPolicy.SharedConfiguration = sharedConfiguration.SharedConfigurationCU.Id;
            }
            else
            {
                roleAssignmentResults = this.ConfigurationSession.FindRoleAssignmentsByUserIds(new ADObjectId[]
                {
                    roleAssignmentPolicy.Id
                }, false);
            }
            roleAssignmentPolicy.PopulateRoles(roleAssignmentResults);
            base.WriteResult(roleAssignmentPolicy);
        }
Exemple #6
0
        public static AdminAuditLogConfig GetAdminAuditLogConfig(IConfigurationSession configSession)
        {
            OrganizationId currentOrganizationId = configSession.SessionSettings.CurrentOrganizationId;

            AdminAuditLogHelper.Tracer.TraceDebug <OrganizationId>(0L, "AdminAuditLogHelper: Will retrieve config objects from AD for OrganizationId: {0}", currentOrganizationId);
            SharedConfiguration   sharedConfiguration  = SharedConfiguration.GetSharedConfiguration(currentOrganizationId);
            IConfigurationSession configurationSession = configSession;

            if (sharedConfiguration != null)
            {
                configurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(configSession.ConsistencyMode, sharedConfiguration.GetSharedConfigurationSessionSettings(), 160, "GetAdminAuditLogConfig", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\AdminAuditLog\\AdminAuditLogHelper.cs");
            }
            configurationSession.SessionSettings.IsSharedConfigChecked = true;
            bool includeCNFObject = configurationSession.SessionSettings.IncludeCNFObject;

            AdminAuditLogConfig[] array;
            try
            {
                configurationSession.SessionSettings.IncludeCNFObject = false;
                array = configurationSession.Find <AdminAuditLogConfig>(null, QueryScope.SubTree, null, null, 2);
            }
            finally
            {
                configurationSession.SessionSettings.IncludeCNFObject = includeCNFObject;
            }
            if (array.Length == 0)
            {
                AdminAuditLogHelper.Tracer.TraceDebug <OrganizationId>(0L, "AdminAuditLogHelper: No AdminAuditLogConfig was found in org {0}.", currentOrganizationId);
                AdminAuditLogHelper.WriteNoAdminAuditLogWarningAsNeed(configSession);
                return(null);
            }
            if (array.Length > 1)
            {
                AdminAuditLogHelper.Tracer.TraceDebug <OrganizationId>(0L, "AdminAuditLogHelper: More than one AdminAuditLogConfig was found in org {0}.", currentOrganizationId);
                ExManagementApplicationLogger.LogEvent(currentOrganizationId, ManagementEventLogConstants.Tuple_MultipleAdminAuditLogConfig, new string[]
                {
                    currentOrganizationId.ToString()
                });
                throw new MultipleAdminAuditLogConfigException(currentOrganizationId.ToString());
            }
            AdminAuditLogHelper.Tracer.TraceDebug <OrganizationId, bool>(0L, "AdminAuditLogHelper: One AdminAuditLogConfig was found in org {0}. Logging enabled is {1}.", currentOrganizationId, array[0].AdminAuditLogEnabled);
            return(array[0]);
        }
        // Token: 0x06000E61 RID: 3681 RVA: 0x000568D8 File Offset: 0x00054AD8
        private static SharingPolicyCache GetDehydratedPolicyFromCacheOrAD(OrganizationId orgId, ADObjectId policyId)
        {
            SharingPolicyCache sharingPolicyCache;

            if (policyId != SharingPolicyCache.DynamicDefaultPolicy)
            {
                lock (SharingPolicyCache.cacheSyncLock)
                {
                    if (SharingPolicyCache.dehydratedDefaultCache.TryGetValue(policyId.ObjectGuid, out sharingPolicyCache))
                    {
                        SharingPolicyCache.Tracer.TraceDebug <ADObjectId>(0L, "Found Sharing Policy {0} in dehydrated cache.", policyId);
                        return(sharingPolicyCache);
                    }
                }
            }
            SharedConfiguration   sharedConfiguration = SharedConfiguration.GetSharedConfiguration(orgId);
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, sharedConfiguration.GetSharedConfigurationSessionSettings(), 282, "GetDehydratedPolicyFromCacheOrAD", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\SharingPolicy\\SharingPolicyCache.cs");

            tenantOrTopologyConfigurationSession.SessionSettings.IsSharedConfigChecked = true;
            bool flag2 = policyId == SharingPolicyCache.DynamicDefaultPolicy;

            if (flag2)
            {
                SharingPolicyCache.Tracer.TraceDebug <OrganizationId>(0L, "Find Default Policy Id for Org {0} ", orgId);
                policyId = SharingPolicyCache.GetDefaultSharingPolicyId(tenantOrTopologyConfigurationSession);
                if (policyId == null)
                {
                    return(null);
                }
                lock (SharingPolicyCache.cacheSyncLock)
                {
                    if (SharingPolicyCache.dehydratedDefaultCache.TryGetValue(policyId.ObjectGuid, out sharingPolicyCache))
                    {
                        SharingPolicyCache.Tracer.TraceDebug <ADObjectId>(0L, "Found Sharing Policy {0} in dehydrated cache.", policyId);
                        return(sharingPolicyCache);
                    }
                }
            }
            SharingPolicy sharingPolicy = tenantOrTopologyConfigurationSession.Read <SharingPolicy>(policyId);

            if (sharingPolicy == null)
            {
                SharingPolicyCache.Tracer.TraceError <ADObjectId, bool>(0L, "Unable to find SharingPolicy {0} in the AD. PolicyId is default:{1}", policyId, flag2);
                return(null);
            }
            sharingPolicyCache = new SharingPolicyCache(sharingPolicy, true);
            lock (SharingPolicyCache.cacheSyncLock)
            {
                SharingPolicyCache.dehydratedDefaultCache[policyId.ObjectGuid] = sharingPolicyCache;
            }
            return(sharingPolicyCache);
        }
        public DataClassificationConfig GetDataClassificationConfig(OrganizationId organizationId, IConfigurationSession currentDataSession)
        {
            if (object.ReferenceEquals(null, organizationId))
            {
                throw new ArgumentNullException("organizationId");
            }
            if (currentDataSession == null)
            {
                throw new ArgumentNullException("currentDataSession");
            }
            if (!VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled || OrganizationId.ForestWideOrgId.Equals(organizationId))
            {
                return(null);
            }
            if (!organizationId.Equals(currentDataSession.SessionSettings.CurrentOrganizationId))
            {
                throw new ArgumentException(new ArgumentException().Message, "currentDataSession");
            }
            SharedConfiguration   sharedConfiguration = SharedConfiguration.GetSharedConfiguration(organizationId);
            IConfigurationSession configurationSession;

            if (sharedConfiguration != null)
            {
                configurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(true, ConsistencyMode.PartiallyConsistent, sharedConfiguration.GetSharedConfigurationSessionSettings(), 1186, "GetDataClassificationConfig", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\ClassificationDefinitions\\ClassificationDefinitionUtils.cs");
            }
            else
            {
                configurationSession = currentDataSession;
            }
            DataClassificationConfig[] array = configurationSession.Find <DataClassificationConfig>(null, QueryScope.SubTree, null, null, 1);
            ExAssert.RetailAssert(array != null && 1 == array.Length, "There should be one and only one DataClassificationConfig applicable to a particular tenant.");
            return(array[0]);
        }
Exemple #9
0
        internal static RoleGroup PopulateRoleAssignmentsAndConvert(ADGroup group, IConfigurationSession configurationSession)
        {
            Result <ExchangeRoleAssignment>[] roleAssignmentResults = null;
            if (RoleGroup.ContainsRoleAssignments(group))
            {
                return(new RoleGroup(group, roleAssignmentResults));
            }
            SharedConfiguration sharedConfiguration = SharedConfiguration.GetSharedConfiguration(group.OrganizationId);
            RoleGroup           roleGroup;

            if (sharedConfiguration != null)
            {
                if (group.RoleGroupType == RoleGroupType.PartnerLinked)
                {
                    roleGroup = new RoleGroup(group, null);
                }
                else
                {
                    ADObjectId   sharedConfiguration2 = null;
                    ADObjectId[] sharedRoleGroupIds;
                    if (group.IsModified(ADObjectSchema.Name))
                    {
                        sharedRoleGroupIds = sharedConfiguration.GetSharedRoleGroupIds(new ADObjectId[]
                        {
                            group.OriginalId
                        });
                    }
                    else
                    {
                        sharedRoleGroupIds = sharedConfiguration.GetSharedRoleGroupIds(new ADObjectId[]
                        {
                            group.Id
                        });
                    }
                    if (sharedRoleGroupIds != null && sharedRoleGroupIds.Length != 0)
                    {
                        IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, sharedConfiguration.GetSharedConfigurationSessionSettings(), 171, "PopulateRoleAssignmentsAndConvert", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RBAC\\RoleGroup\\RoleGroupCommon.cs");
                        roleAssignmentResults = tenantOrTopologyConfigurationSession.FindRoleAssignmentsByUserIds(new ADObjectId[]
                        {
                            sharedRoleGroupIds[0]
                        }, false);
                        sharedConfiguration2 = sharedConfiguration.SharedConfigurationCU.Id;
                    }
                    roleGroup = new RoleGroup(group, roleAssignmentResults);
                    roleGroup.SharedConfiguration = sharedConfiguration2;
                }
            }
            else
            {
                configurationSession.SessionSettings.IsSharedConfigChecked = true;
                roleAssignmentResults = configurationSession.FindRoleAssignmentsByUserIds(new ADObjectId[]
                {
                    group.Id
                }, false);
                roleGroup = new RoleGroup(group, roleAssignmentResults);
            }
            return(roleGroup);
        }
        internal static ExchangeAssistance GetExchangeAssistanceObjectFromAD(OrganizationId organizationId)
        {
            ExchangeAssistance result = null;

            try
            {
                IConfigurationSession configurationSession;
                ADObjectId            adobjectId;
                if (organizationId == OrganizationId.ForestWideOrgId)
                {
                    configurationSession = HelpProvider.GetOrganizationConfigurationSession(organizationId);
                    adobjectId           = configurationSession.GetOrgContainerId();
                }
                else
                {
                    SharedConfiguration sharedConfiguration = SharedConfiguration.GetSharedConfiguration(organizationId);
                    if (sharedConfiguration != null)
                    {
                        adobjectId           = sharedConfiguration.SharedConfigurationCU.Id;
                        configurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, sharedConfiguration.GetSharedConfigurationSessionSettings(), 955, "GetExchangeAssistanceObjectFromAD", "f:\\15.00.1497\\sources\\dev\\UA\\src\\HelpProvider\\HelpProvider.cs");
                    }
                    else
                    {
                        adobjectId           = organizationId.ConfigurationUnit;
                        configurationSession = HelpProvider.GetOrganizationConfigurationSession(organizationId);
                    }
                }
                ADObjectId childId = adobjectId.GetChildId("ExchangeAssistance").GetChildId(HelpProvider.CurrentVersionExchangeAssistanceContainerName);
                result = configurationSession.Read <ExchangeAssistance>(childId);
            }
            catch (ADTransientException ex)
            {
                ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "ADTransient Exception in LoadBaseURL: {0}", ex.Message);
            }
            catch (ADOperationException ex2)
            {
                ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "ADOperationException in LoadBaseURL: {0}", ex2.Message);
            }
            return(result);
        }