https://github.com/micromdm/mdm
common library for mdm command payloads and responses.
https://github.com/micromdm/mdm
go golang mdm
Last synced: 6 months ago
JSON representation
common library for mdm command payloads and responses.
- Host: GitHub
- URL: https://github.com/micromdm/mdm
- Owner: micromdm
- License: mit
- Archived: true
- Created: 2016-03-08T21:31:51.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-03-08T13:28:28.000Z (over 8 years ago)
- Last Synced: 2025-08-14T01:19:28.217Z (11 months ago)
- Topics: go, golang, mdm
- Language: Go
- Size: 44.9 KB
- Stars: 21
- Watchers: 8
- Forks: 16
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://godoc.org/github.com/micromdm/mdm) [](https://travis-ci.org/micromdm/mdm)
The mdm package holds structs and helper methods for payloads in Apple's Mobile Device Management protocol.
This package embeds the various payloads and responses in two structs - `Payload` and `Response`.
# How an MDM server executes commands on a device.
To communicate with a device, an MDM server must create a Payload property list with a specific RequestType and additional data for each request type. Let's use the DeviceInformation request as an example:
```
// create a request
request := &CommandRequest{
RequestType: "DeviceInformation",
Queries: []string{"IsCloudBackupEnabled", "BatteryLevel"},
}
// NewPayload will create a proper Payload based on the CommandRequest struct
payload, err := NewPayload(request)
if err != nil {
log.Fatal(err)
}
// Encode in a plist and print to stdout
// uses the github.com/groob/plist package
encoder := plist.NewEncoder(os.Stdout)
encoder.Indent(" ")
if err := encoder.Encode(payload); err != nil {
log.Fatal(err)
}
```
Resulting command payload:
```
Command
Queries
IsCloudBackupEnabled
BatteryLevel
RequestType
DeviceInformation
CommandUUID
fa34b4b7-0553-4b3a-9c4b-76b8b357a622
```
An MDM server will queue this request and send a push notification to a device. When device checks in, the server will
reply with the queued plist.
Once the device receives and processes the payload plist, it will reply back to the server. The response will be another plist, which can be unmarshalled into the `Response` struct. Below is the response to our DeviceInformation request.
```
CommandUUID
fa34b4b7-0553-4b3a-9c4b-76b8b357a622
QueryResponses
BatteryLevel
1
IsCloudBackupEnabled
Status
Acknowledged
UDID
1111111111111111111111111111111111111111
```