public static bool TryGetManagedGroup(DeviceProfile DeviceProfile, out DeviceProfileDevicesManagedGroup ManagedGroup) { ADManagedGroup managedGroup; string key = GetKey(DeviceProfile); if (ActiveDirectory.Context.ManagedGroups.TryGetValue(key, out managedGroup)) { ManagedGroup = (DeviceProfileDevicesManagedGroup)managedGroup; return true; } else { ManagedGroup = null; return false; } }
public static DeviceProfileDevicesManagedGroup Initialize(DeviceProfile DeviceProfile) { if (DeviceProfile.Id > 0) { var key = GetKey(DeviceProfile); if (!string.IsNullOrEmpty(DeviceProfile.DevicesLinkedGroup)) { var config = ADManagedGroup.ConfigurationFromJson(DeviceProfile.DevicesLinkedGroup); if (config != null && !string.IsNullOrWhiteSpace(config.GroupId)) { var group = new DeviceProfileDevicesManagedGroup( key, config, DeviceProfile); // Add to AD Context ActiveDirectory.Context.ManagedGroups.AddOrUpdate(group); return group; } } // Remove from AD Context ActiveDirectory.Context.ManagedGroups.Remove(key); } return null; }