-
Notifications
You must be signed in to change notification settings - Fork 8
/
CreateLDAPServer.go
97 lines (90 loc) · 3.49 KB
/
CreateLDAPServer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package main
import (
"fmt"
"log"
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
)
func main() {
// Define the path to the JSON configuration file
configFilePath := "/Users/dafyddwatkins/localtesting/jamfpro/clientconfig.json"
// Initialize the Jamf Pro client with the HTTP client configuration
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
if err != nil {
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
}
// Define the LDAP server details
ldapServer := &jamfpro.ResourceLDAPServers{
Connection: jamfpro.LDAPServerSubsetConnection{
Name: "Company Active Directory",
Hostname: "company.ad.com",
ServerType: "Active Directory",
Port: 389,
UseSSL: true,
AuthenticationType: "simple",
Account: jamfpro.LDAPServerSubsetConnectionAccount{
DistinguishedUsername: "CN=Administrator,CN=Users,DC=Company,DC=com",
Password: "password",
},
OpenCloseTimeout: 15,
SearchTimeout: 60,
ReferralResponse: "ignore",
UseWildcards: true,
// Additional fields if necessary...
},
MappingsForUsers: jamfpro.LDAPServerContainerMapping{
UserMappings: jamfpro.LDAPServerSubsetMappingUsers{
MapObjectClassToAnyOrAll: "all",
ObjectClasses: "organizationalPerson, user",
SearchBase: "DC=Company,DC=com",
SearchScope: "All Subtrees",
MapUserID: "uSNCreated",
MapUsername: "sAMAccountName",
MapRealName: "displayName",
MapEmailAddress: "mail",
AppendToEmailResults: "company.com",
MapDepartment: "department",
MapBuilding: "streetAddress",
MapRoom: "room",
MapTelephone: "telephoneNumber",
MapPosition: "title",
MapUserUUID: "objectGUID",
// Additional fields if necessary...
},
UserGroupMappings: jamfpro.LDAPServerSubsetMappingUserGroups{
MapObjectClassToAnyOrAll: "all",
ObjectClasses: "top, group",
SearchBase: "DC=Company,DC=com",
SearchScope: "All Subtrees",
MapGroupID: "uSNCreated",
MapGroupName: "name",
MapGroupUUID: "objectGUID",
// Additional fields if necessary...
},
UserGroupMembershipMappings: jamfpro.LDAPServerSubsetMappingUserGroupMemberships{
UserGroupMembershipStoredIn: "user object",
MapGroupMembershipToUserField: "memberOf",
AppendToUsername: "company.com",
UseDN: true,
RecursiveLookups: true,
MapUserMembershipToGroupField: true,
MapUserMembershipUseDN: true,
MapObjectClassToAnyOrAll: "all",
ObjectClasses: "group",
SearchBase: "DC=Company,DC=com",
SearchScope: "All Subtrees",
Username: "sAMAccountName",
GroupID: "uSNCreated",
UserGroupMembershipUseLDAPCompare: true,
// Additional fields if necessary...
},
// Additional fields if necessary...
},
}
// Call the CreateLDAPServer function
createdLDAPServer, err := client.CreateLDAPServer(ldapServer)
if err != nil {
log.Fatalf("Error creating LDAP server: %v", err)
}
// Print the details of the created LDAP server
fmt.Printf("Created LDAP Server: %+v\n", createdLDAPServer)
}