internal static void SetAvailabilityAces(SecurityIdentifier exchangeServersSid, AvailabilityConfig availabilityConfig, Task.TaskVerboseLoggingDelegate verboseLogger) { Guid schemaGuid; using (ActiveDirectorySchema currentSchema = ActiveDirectorySchema.GetCurrentSchema()) { using (ActiveDirectorySchemaClass activeDirectorySchemaClass = currentSchema.FindClass("msExchAvailabilityAddressSpace")) { schemaGuid = activeDirectorySchemaClass.SchemaGuid; } } Guid schemaGuid2; using (ActiveDirectorySchema currentSchema2 = ActiveDirectorySchema.GetCurrentSchema()) { using (ActiveDirectorySchemaProperty activeDirectorySchemaProperty = currentSchema2.FindProperty("msExchAvailabilityUserPassword")) { schemaGuid2 = activeDirectorySchemaProperty.SchemaGuid; } } DirectoryCommon.SetAces(verboseLogger, null, availabilityConfig, new List <ActiveDirectoryAccessRule> { new ActiveDirectoryAccessRule(exchangeServersSid, ActiveDirectoryRights.ReadProperty, AccessControlType.Allow, schemaGuid2, ActiveDirectorySecurityInheritance.Descendents, schemaGuid) }.ToArray()); }
public void TestSchema() { using (ActiveDirectorySchema schema = ActiveDirectorySchema.GetSchema(ActiveDirectoryContext)) { Assert.True(schema.FindAllClasses().Contains(ActiveDirectorySchemaClass.FindByName(ActiveDirectoryContext, "user"))); Assert.True(schema.FindAllClasses().Contains(ActiveDirectorySchemaClass.FindByName(ActiveDirectoryContext, "samDomainBase"))); Assert.NotNull(schema.FindAllDefunctClasses()); Assert.NotNull(schema.FindAllDefunctProperties()); Assert.True(schema.FindAllProperties(PropertyTypes.Indexed).Contains(ActiveDirectorySchemaProperty.FindByName(ActiveDirectoryContext, "ou"))); Assert.True(schema.FindAllProperties().Contains(ActiveDirectorySchemaProperty.FindByName(ActiveDirectoryContext, "cn"))); Assert.Equal("person", schema.FindClass("person").Name); Assert.Equal("cn", schema.FindProperty("cn").Name); using (DirectoryEntry de = schema.GetDirectoryEntry()) { Assert.True("CN=Schema".Equals(de.Name, StringComparison.OrdinalIgnoreCase)); } } }
private static SchemaProperty GetSchemaProperty(string propertyName) { if (!schemaPropertyCache.TryGetValue(propertyName, out SchemaProperty schemaProperty)) { using (ActiveDirectorySchema schema = ActiveDirectorySchema.GetCurrentSchema()) { ActiveDirectorySchemaProperty result = schema.FindProperty(propertyName); System.DirectoryServices.DirectoryEntry directoryEntry = result.GetDirectoryEntry(); schemaProperty = new SchemaProperty() { LdapDisplayName = result.Name, SchemaGuid = result.SchemaGuid, IsConfidential = (((int)directoryEntry.Properties["searchFlags"][0] & 128) == 128) }; schemaPropertyCache.Add(result.Name, schemaProperty); } } return(schemaProperty); }