protected override void PreDeleteInsideTransaction(BusinessContext context) { base.PreDeleteInsideTransaction(context); DirectoryOrganizationalUnitEntity entity = (DirectoryOrganizationalUnitEntity)BusinessManager.Load(DirectoryOrganizationalUnitEntity.ClassName, context.GetTargetPrimaryKeyId().Value); if (entity.ParentId == null) { throw new AccessDeniedException("Can not delete root."); } // TODO: Child Business Unit // TODO: Delete Users // TODO: Delete Team // TODO: Delete Role // Remove BusinessUnit From Principal DirectoryManager.DeletePrincipal(context.GetTargetPrimaryKeyId().Value); // Remove BusinessUnitScopeId From Principal DirectoryManager.DeletePrincipal((PrimaryKeyId)entity.OrganizationalUnitScopeId); }
protected override void PreDeleteInsideTransaction(BusinessContext context) { base.PreDeleteInsideTransaction(context); // Remove SecureRole From Principal DirectoryManager.DeletePrincipal(context.GetTargetPrimaryKeyId().Value); }
protected override void PostCreateInsideTransaction(BusinessContext context) { base.PostCreateInsideTransaction(context); // Add SecureRole To Principal DirectoryManager.CreatePrincipal(DirectoryPrincipalType.SecureRole, ((CreateResponse)context.Response).PrimaryKeyId, ((DirectorySecureRoleEntity)context.Request.Target).Name); }
protected override void PostUpdateInsideTransaction(BusinessContext context) { base.PostUpdateInsideTransaction(context); // Principal if (context.Request.Target.Properties.Contains(DirectorySecureRoleEntity.FieldName)) { DirectoryManager.UpdatePrincipal(context.GetTargetPrimaryKeyId().Value, (string)context.Request.Target[DirectorySecureRoleEntity.FieldName]); } }
protected override void PostCreateInsideTransaction(BusinessContext context) { base.PostCreateInsideTransaction(context); // Add BusinessUnit To Principal DirectoryManager.CreatePrincipal(DirectoryPrincipalType.OrganizationalUnit, ((CreateResponse)context.Response).PrimaryKeyId, ((DirectoryOrganizationalUnitEntity)context.Request.Target).Name); // Add BusinessUnitScope To Principal DirectoryManager.CreatePrincipal(DirectoryPrincipalType.OrganizationalUnitScope, (PrimaryKeyId)((DirectoryOrganizationalUnitEntity)context.Request.Target).OrganizationalUnitScopeId, ((DirectoryOrganizationalUnitEntity)context.Request.Target).Name); }
protected override void PostUpdateInsideTransaction(BusinessContext context) { base.PostUpdateInsideTransaction(context); // Principal if (context.Request.Target.Properties.Contains(DirectoryOrganizationalUnitEntity.FieldName)) { DirectoryOrganizationalUnitEntity entity = (DirectoryOrganizationalUnitEntity)BusinessManager.Load(DirectoryOrganizationalUnitEntity.ClassName, context.GetTargetPrimaryKeyId().Value); DirectoryManager.UpdatePrincipal(context.GetTargetPrimaryKeyId().Value, (string)context.Request.Target[DirectoryOrganizationalUnitEntity.FieldName]); DirectoryManager.UpdatePrincipal((PrimaryKeyId)entity.OrganizationalUnitScopeId, (string)context.Request.Target[DirectoryOrganizationalUnitEntity.FieldName]); } }