π Intune.cs Documentation
Module:
IrbyImaging.DomainClasses
File:Intune.cs
Schema:irby.Intune
π Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Data Model: Intune Entity
- UML Class Diagram
- Usage Examples
- ThirdβParty Integrations
- Helper Methods & Utilities
- Error Handling & Return Types
- Conclusion
π 1. Overview & Purpose
The Intune class is a Domain Model used to represent Microsoft Intune device information within the IRBY Imaging application. It leverages Entity Framework Core to map properties directly to the irby.Intune database table.
This model is primarily responsible for:
- Tracking device compliance and enrollment data.
- Storing hardware identifiers (IMEI, MEID, serial numbers).
- Logging last check-in and sync timestamps.
- Exposing user-related ownership and primary user details.
π οΈ 2. Dependencies & Technologies
- .NET 6+ / .NET Framework (>=4.6.1)
- Entity Framework Core
System.ComponentModel.DataAnnotationsSystem.ComponentModel.DataAnnotations.Schema
- C# POCO (Plain Old CLR Object)
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
π 3. Data Model: Intune Entity
π Table Mapping & Key
[Table("Intune", Schema = "irby")]
public class Intune
{
[Key]
public Guid IntuneId { get; set; }
// ... other properties ...
}
- [Table] attribute maps this class to the
irby.Intunetable. - [Key] marks
IntuneIdas the primary key.
π Entity Properties
| Property | Type | Description |
|---|---|---|
| IntuneId | Guid |
Primary key (Intune record identifier) |
| AssetId | Guid |
Foreign key linking to an Asset entity |
| DeviceId | string |
Unique Intune device identifier |
| DeviceNameManagedByOwnership | string |
The device name as managed by ownership policy |
| Compliance | string |
Compliance state (e.g., Compliant, Noncompliant) |
| ComplianceGracePeriodExpiration | DateTime |
Ends the grace period for compliance |
| OS | string |
Operating system name (e.g., iOS, Android, Windows) |
| OSVersion | string |
OS version string |
| DeviceState | string |
Device lifecycle state (e.g., active, retired) |
| PrimaryUserEmailAddress | string |
Email address of the primary user |
| PrimaryUserUPN | string |
User Principal Name of the primary user |
| LastCheckIn | DateTime |
Timestamp of the last device check-in |
| EnrollmentDateIMEI | string |
Enrollment date or IMEI string |
| EASActivated | bool |
Whether Exchange ActiveSync is activated |
| EASActivationId | string |
Activation identifier for EAS |
| IntuneRegistered | string |
Registration status with Intune |
| JailBroken | string |
Jailbreak/root status (Yes/No) |
| Supervised | string |
Supervision status (iOS supervised devices) |
| Category | string |
Device category (e.g., corporate, personal) |
| LastEASSyncTime | DateTime |
Timestamp of the last EAS sync |
| EASStatus | string |
Current EAS status |
| EASReason | string |
Reason for EAS compliance failures |
| Encrypted | string |
Disk encryption status |
| Model | string |
Device model name (e.g., iPhone X, Surface Pro) |
| Manufacturer | string |
Device manufacturer (e.g., Apple, Microsoft) |
| SerialNumber | string |
Factory serial number |
| PhoneNumber | string |
Assigned phone number |
| PrimaryUserDisplayName | string |
Display name of the primary user |
| SecurityPatchLevel | string |
OS security patch level |
| WiFiMAC | string |
MAC address of the Wi-Fi adapter |
| MEID | string |
Mobile Equipment Identifier (CDMA networks) |
| SubscriberCarrier | string |
Cellular network operator |
| TotalStorage | string |
Total device storage capacity |
| FreeStorage | string |
Remaining free storage |
| ManagementName | string |
MDM management profile name |
| AzureADDeviceId | string |
Azure Active Directory device GUID |
| AzureADRegistered | string |
Azure AD registration status |
| JoinType | string |
Azure AD join type (e.g., AzureAD, Hybrid) |
| SkuFamily | string |
SKU family designation |
| ManagementCertificateExpirationDate | DateTime |
Expiry date of the management certificate |
π 4. UML Class Diagram
classDiagram
class Intune {
<<Entity>>
+Guid IntuneId
+Guid AssetId
+string DeviceId
+string DeviceNameManagedByOwnership
+string Compliance
+DateTime ComplianceGracePeriodExpiration
+string OS
+string OSVersion
+string DeviceState
+string PrimaryUserEmailAddress
+string PrimaryUserUPN
+DateTime LastCheckIn
+string EnrollmentDateIMEI
+bool EASActivated
+string EASActivationId
+string IntuneRegistered
+string JailBroken
+string Supervised
+string Category
+DateTime LastEASSyncTime
+string EASStatus
+string EASReason
+string Encrypted
+string Model
+string Manufacturer
+string SerialNumber
+string PhoneNumber
+string PrimaryUserDisplayName
+string SecurityPatchLevel
+string WiFiMAC
+string MEID
+string SubscriberCarrier
+string TotalStorage
+string FreeStorage
+string ManagementName
+string AzureADDeviceId
+string AzureADRegistered
+string JoinType
+string SkuFamily
+DateTime ManagementCertificateExpirationDate
}
π 5. Usage Examples
5.1. Retrieving Data via Entity Framework
using (var context = new IrbyDbContext())
{
// Query a device by its IntuneId
Guid id = /* some GUID */;
Intune device = context.Set<Intune>()
.FirstOrDefault(i => i.IntuneId == id);
Console.WriteLine($"Device: {device.DeviceNameManagedByOwnership}, OS: {device.OSVersion}");
}
5.2. Creating a New Record
var newDevice = new Intune {
IntuneId = Guid.NewGuid(),
AssetId = existingAssetId,
DeviceId = "ABC12345",
OS = "iOS",
OSVersion = "14.6",
Compliance = "Compliant",
LastCheckIn = DateTime.UtcNow,
ManagementCertificateExpirationDate = DateTime.UtcNow.AddMonths(6)
// ... set other required fields ...
};
using (var context = new IrbyDbContext())
{
context.Add(newDevice);
context.SaveChanges();
}
π 6. ThirdβParty Integrations
- Microsoft Intune API:
- This model is designed to hold data imported from the Microsoft Graph Intune endpoints (e.g.,
/deviceManagement/managedDevices).
- This model is designed to hold data imported from the Microsoft Graph Intune endpoints (e.g.,
- Azure Active Directory:
- Fields like
AzureADDeviceId,AzureADRegistered, andJoinTypecorrelate to Azure AD device registration status.
- Fields like
π§° 7. Helper Methods & Utilities
This class is a pure data model and does not contain any helper methods or business logic.
All utility operations (mapping, transformation) should be implemented in service or repository layers.
β οΈ 8. Error Handling & Return Types
- As an EF Core entity, validation errors will be thrown as exceptions by the DbContext on
SaveChanges(). - There are no custom return types within this file; error handling must be implemented externally.
π 9. Conclusion
The Intune domain class provides a comprehensive schema for persisting Intune-managed device details. By leveraging EF Core attributes, it seamlessly maps to the irby.Intune table, enabling CRUD operations on device compliance, enrollment status, hardware identifiers, and more.
Feel free to extend this model with navigation properties or DTOs for API layer consumption. Happy coding! π