Skip to content

Commit c2662b8

Browse files
author
ShocOne
committed
+ sdk coverage for ldap servers
1 parent 910186d commit c2662b8

File tree

19 files changed

+1306
-370
lines changed

19 files changed

+1306
-370
lines changed

README.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,11 +777,59 @@ This documentation outlines the API endpoints available for managing iBeacons wi
777777
- [x] ✅ **DELETE** `/JSSResource/ibeacons/name/{name}`
778778
`DeleteIBeaconByName` deletes an iBeacon by its name.
779779
780+
### Jamf Pro Classic API - LDAP Servers
781+
782+
This documentation outlines the API endpoints available for managing LDAP servers within Jamf Pro using the Classic API, which supports XML data structures.
783+
784+
## Endpoints
785+
786+
- [x] ✅ **GET** `/JSSResource/ldapservers`
787+
`GetLDAPServers` retrieves a serialized list of all LDAP servers.
788+
789+
- [x] ✅ **GET** `/JSSResource/ldapservers/id/{id}`
790+
`GetLDAPServerByID` fetches a single LDAP server by its ID.
791+
792+
- [x] ✅ **GET** `/JSSResource/ldapservers/name/{name}`
793+
`GetLDAPServerByName` retrieves a LDAP server by its name.
794+
795+
- [x] ✅ **GET** `/JSSResource/ldapservers/id/{id}/user/{user}`
796+
`GetLDAPServerByIDAndUserDataSubset` retrieves user data for a specific LDAP server by its ID.
797+
798+
- [x] ✅ **GET** `/JSSResource/ldapservers/id/{id}/group/{group}`
799+
`GetLDAPServerByIDAndGroupDataSubset` retrieves group data for a specific LDAP server by its ID.
800+
801+
- [x] ✅ **GET** `/JSSResource/ldapservers/id/{id}/group/{group}/user/{user}`
802+
`GetLDAPServerByIDAndUserMembershipInGroupDataSubset` retrieves user group membership details for a specific LDAP server by its ID.
803+
804+
- [x] ✅ **GET** `/JSSResource/ldapservers/name/{name}/user/{user}`
805+
`GetLDAPServerByNameAndUserDataSubset` retrieves user data for a specific LDAP server by its name.
806+
807+
- [x] ✅ **GET** `/JSSResource/ldapservers/name/{name}/group/{group}`
808+
`GetLDAPServerByNameAndGroupDataSubset` retrieves group data for a specific LDAP server by its name.
809+
810+
- [x] ✅ **GET** `/JSSResource/ldapservers/name/{name}/group/{group}/user/{user}`
811+
`GetLDAPServerByNameAndUserMembershipInGroupDataSubset` retrieves user group membership details for a specific LDAP server by its name.
812+
813+
- [x] ✅ **POST** `/JSSResource/ldapservers/id/0`
814+
`CreateLDAPServer` creates a new LDAP server with the provided details.
815+
816+
- [x] ✅ **PUT** `/JSSResource/ldapservers/id/{id}`
817+
`UpdateLDAPServerByID` updates an existing LDAP server by its ID.
818+
819+
- [x] ✅ **PUT** `/JSSResource/ldapservers/name/{name}`
820+
`UpdateLDAPServerByName` updates an existing LDAP server by its name.
821+
822+
- [x] ✅ **DELETE** `/JSSResource/ldapservers/id/{id}`
823+
`DeleteLDAPServerByID` deletes an LDAP server by its ID.
824+
825+
- [x] ✅ **DELETE** `/JSSResource/ldapservers/name/{name}`
826+
`DeleteLDAPServerByName` deletes an LDAP server by its name.
827+
780828
781829
## Progress Summary
782830
783-
- Total Endpoints: 262
784-
- Covered: 243
831+
- Total Endpoints: 276
832+
- Covered: 257
785833
- Not Covered: 19
786834
- Partially Covered: 0
787835
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
7+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
9+
)
10+
11+
func main() {
12+
// Define the path to the JSON configuration file for OAuth credentials
13+
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
14+
15+
// Load the client OAuth credentials from the configuration file
16+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
17+
if err != nil {
18+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
19+
}
20+
21+
// Configuration for the jamfpro client
22+
config := jamfpro.Config{
23+
InstanceName: authConfig.InstanceName,
24+
LogLevel: http_client.LogLevelDebug,
25+
Logger: http_client.NewDefaultLogger(),
26+
ClientID: authConfig.ClientID,
27+
ClientSecret: authConfig.ClientSecret,
28+
}
29+
30+
// Create a new jamfpro client instance
31+
client, err := jamfpro.NewClient(config)
32+
if err != nil {
33+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
34+
}
35+
36+
// Define the LDAP server details
37+
ldapServer := &jamfpro.ResponseLDAPServers{
38+
Connection: jamfpro.LDAPConnection{
39+
Name: "Company Active Directory",
40+
Hostname: "company.ad.com",
41+
ServerType: "Active Directory",
42+
Port: 389,
43+
UseSSL: true,
44+
AuthenticationType: "simple",
45+
Account: jamfpro.LDAPAccount{
46+
DistinguishedUsername: "CN=Administrator,CN=Users,DC=Company,DC=com",
47+
Password: "password",
48+
},
49+
OpenCloseTimeout: 15,
50+
SearchTimeout: 60,
51+
ReferralResponse: "ignore",
52+
UseWildcards: true,
53+
// Additional fields if necessary...
54+
},
55+
MappingsForUsers: jamfpro.LDAPMappingsForUsers{
56+
UserMappings: jamfpro.LDAPUserMappings{
57+
MapObjectClassToAnyOrAll: "all",
58+
ObjectClasses: "organizationalPerson, user",
59+
SearchBase: "DC=Company,DC=com",
60+
SearchScope: "All Subtrees",
61+
MapUserID: "uSNCreated",
62+
MapUsername: "sAMAccountName",
63+
MapRealName: "displayName",
64+
MapEmailAddress: "mail",
65+
AppendToEmailResults: "company.com",
66+
MapDepartment: "department",
67+
MapBuilding: "streetAddress",
68+
MapRoom: "room",
69+
MapTelephone: "telephoneNumber",
70+
MapPosition: "title",
71+
MapUserUUID: "objectGUID",
72+
// Additional fields if necessary...
73+
},
74+
UserGroupMappings: jamfpro.LDAPUserGroupMappings{
75+
MapObjectClassToAnyOrAll: "all",
76+
ObjectClasses: "top, group",
77+
SearchBase: "DC=Company,DC=com",
78+
SearchScope: "All Subtrees",
79+
MapGroupID: "uSNCreated",
80+
MapGroupName: "name",
81+
MapGroupUUID: "objectGUID",
82+
// Additional fields if necessary...
83+
},
84+
UserGroupMembershipMappings: jamfpro.LDAPGroupMembershipMappings{
85+
UserGroupMembershipStoredIn: "user object",
86+
MapGroupMembershipToUserField: "memberOf",
87+
AppendToUsername: "company.com",
88+
UseDN: true,
89+
RecursiveLookups: true,
90+
MapUserMembershipToGroupField: true,
91+
MapUserMembershipUseDN: true,
92+
MapObjectClassToAnyOrAll: "all",
93+
ObjectClasses: "group",
94+
SearchBase: "DC=Company,DC=com",
95+
SearchScope: "All Subtrees",
96+
Username: "sAMAccountName",
97+
GroupID: "uSNCreated",
98+
UserGroupMembershipUseLDAPCompare: true,
99+
// Additional fields if necessary...
100+
},
101+
// Additional fields if necessary...
102+
},
103+
}
104+
105+
// Call the CreateLDAPServer function
106+
createdLDAPServer, err := client.CreateLDAPServer(ldapServer)
107+
if err != nil {
108+
log.Fatalf("Error creating LDAP server: %v", err)
109+
}
110+
111+
// Print the details of the created LDAP server
112+
fmt.Printf("Created LDAP Server: %+v\n", createdLDAPServer)
113+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
7+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
9+
)
10+
11+
func main() {
12+
// Define the path to the JSON configuration file for OAuth credentials
13+
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
14+
15+
// Load the client OAuth credentials from the configuration file
16+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
17+
if err != nil {
18+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
19+
}
20+
21+
// Configuration for the jamfpro client
22+
config := jamfpro.Config{
23+
InstanceName: authConfig.InstanceName,
24+
LogLevel: http_client.LogLevelDebug,
25+
Logger: http_client.NewDefaultLogger(),
26+
ClientID: authConfig.ClientID,
27+
ClientSecret: authConfig.ClientSecret,
28+
}
29+
30+
// Create a new jamfpro client instance
31+
client, err := jamfpro.NewClient(config)
32+
if err != nil {
33+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
34+
}
35+
36+
// Delete LDAP server by ID
37+
id := 1 // Replace with actual LDAP server ID
38+
err = client.DeleteLDAPServerByID(id)
39+
if err != nil {
40+
log.Fatalf("Error deleting LDAP server by ID: %v", err)
41+
}
42+
43+
fmt.Println("LDAP Server deleted successfully")
44+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
7+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
9+
)
10+
11+
func main() {
12+
// Define the path to the JSON configuration file for OAuth credentials
13+
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
14+
15+
// Load the client OAuth credentials from the configuration file
16+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
17+
if err != nil {
18+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
19+
}
20+
21+
// Configuration for the jamfpro client
22+
config := jamfpro.Config{
23+
InstanceName: authConfig.InstanceName,
24+
LogLevel: http_client.LogLevelDebug,
25+
Logger: http_client.NewDefaultLogger(),
26+
ClientID: authConfig.ClientID,
27+
ClientSecret: authConfig.ClientSecret,
28+
}
29+
30+
// Create a new jamfpro client instance
31+
client, err := jamfpro.NewClient(config)
32+
if err != nil {
33+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
34+
}
35+
36+
// Delete LDAP server by name
37+
name := "Company Active Directory" // Replace with actual LDAP server name
38+
err = client.DeleteLDAPServerByName(name)
39+
if err != nil {
40+
log.Fatalf("Error deleting LDAP server by name: %v", err)
41+
}
42+
43+
fmt.Println("LDAP Server deleted successfully")
44+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package main
2+
3+
import (
4+
"encoding/xml"
5+
"fmt"
6+
"log"
7+
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
9+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
10+
)
11+
12+
func main() {
13+
// Define the path to the JSON configuration file for OAuth credentials
14+
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
15+
16+
// Load the client OAuth credentials from the configuration file
17+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
18+
if err != nil {
19+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
20+
}
21+
22+
// Configuration for the jamfpro client
23+
config := jamfpro.Config{
24+
InstanceName: authConfig.InstanceName,
25+
LogLevel: http_client.LogLevelDebug,
26+
Logger: http_client.NewDefaultLogger(),
27+
ClientID: authConfig.ClientID,
28+
ClientSecret: authConfig.ClientSecret,
29+
}
30+
31+
// Create a new jamfpro client instance
32+
client, err := jamfpro.NewClient(config)
33+
if err != nil {
34+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
35+
}
36+
37+
// Call the GetLDAPServerByID function
38+
id := 1 // Replace with actual LDAP server ID
39+
ldapServer, err := client.GetLDAPServerByID(id)
40+
if err != nil {
41+
log.Fatalf("Error retrieving LDAP server by ID: %v", err)
42+
}
43+
44+
// Print the response
45+
ldapServerXML, err := xml.MarshalIndent(ldapServer, "", " ")
46+
if err != nil {
47+
log.Fatalf("Error marshaling LDAP server data: %v", err)
48+
}
49+
fmt.Println("Fetched LDAP Server by ID:", string(ldapServerXML))
50+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package main
2+
3+
import (
4+
"encoding/xml"
5+
"fmt"
6+
"log"
7+
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
9+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
10+
)
11+
12+
func main() {
13+
// Define the path to the JSON configuration file for OAuth credentials
14+
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
15+
16+
// Load the client OAuth credentials from the configuration file
17+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
18+
if err != nil {
19+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
20+
}
21+
22+
// Configuration for the jamfpro client
23+
config := jamfpro.Config{
24+
InstanceName: authConfig.InstanceName,
25+
LogLevel: http_client.LogLevelDebug,
26+
Logger: http_client.NewDefaultLogger(),
27+
ClientID: authConfig.ClientID,
28+
ClientSecret: authConfig.ClientSecret,
29+
}
30+
31+
// Create a new jamfpro client instance
32+
client, err := jamfpro.NewClient(config)
33+
if err != nil {
34+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
35+
}
36+
37+
// Fetch LDAP server group details by ID
38+
ldapServerID := 1 // Replace with actual ID
39+
group := "exampleGroup"
40+
ldapServer, err := client.GetLDAPServerByIDAndGroupDataSubset(ldapServerID, group)
41+
if err != nil {
42+
log.Fatalf("Error retrieving LDAP server group data: %v", err)
43+
}
44+
45+
// Print the response
46+
ldapServerXML, err := xml.MarshalIndent(ldapServer, "", " ")
47+
if err != nil {
48+
log.Fatalf("Error marshaling LDAP server data: %v", err)
49+
}
50+
fmt.Println("Fetched LDAP Server by ID:", string(ldapServerXML))
51+
}

0 commit comments

Comments
 (0)