Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
Signed-off-by: abarreiro <abarreiro@vmware.com>
  • Loading branch information
abarreiro committed Dec 20, 2024
1 parent 150245e commit 3214e60
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 35 deletions.
51 changes: 51 additions & 0 deletions govcd/tm_ldap.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2020 VMware, Inc. All rights reserved. Licensed under the Apache v2 License.
*/

package govcd

import (
"fmt"
"github.com/vmware/go-vcloud-director/v3/types/v56"
)

// TmLdapConfigure configures LDAP for the Tenant Manager "System" organization
func (vcdClient *VCDClient) TmLdapConfigure(settings *types.OrgLdapSettingsType) (*types.OrgLdapSettingsType, error) {
if !vcdClient.Client.IsTm() {
return nil, fmt.Errorf("this method is only supported in TM")
}
return nil, nil
}

// LdapConfigure configures LDAP for the given organization
func (org *TmOrg) LdapConfigure(settings *types.OrgLdapSettingsType) (*types.OrgLdapSettingsType, error) {
return nil, nil
}

// LdapDisable wraps LdapConfigure to disable LDAP configuration for the "System" organization
func (vcdClient *VCDClient) LdapDisable() error {
if !vcdClient.Client.IsTm() {
return fmt.Errorf("this method is only supported in TM")
}
_, err := vcdClient.TmLdapConfigure(&types.OrgLdapSettingsType{OrgLdapMode: types.LdapModeNone})
return err
}

// LdapDisable wraps LdapConfigure to disable LDAP configuration for the given organization
func (org *TmOrg) LdapDisable() error {
_, err := org.LdapConfigure(&types.OrgLdapSettingsType{OrgLdapMode: types.LdapModeNone})
return err
}

// GetLdapConfiguration retrieves LDAP configuration structure for the "System" organization
func (vcdClient *VCDClient) GetLdapConfiguration() (*types.OrgLdapSettingsType, error) {
if !vcdClient.Client.IsTm() {
return nil, fmt.Errorf("this method is only supported in TM")
}
return nil, nil
}

// GetLdapConfiguration retrieves LDAP configuration structure of the given organization
func (org *TmOrg) GetLdapConfiguration() (*types.OrgLdapSettingsType, error) {
return nil, nil
}
70 changes: 35 additions & 35 deletions types/v56/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1112,13 +1112,13 @@ type VAppLeaseSettings struct {
type OrgLdapSettingsType struct {
XMLName xml.Name `xml:"OrgLdapSettings"`
Xmlns string `xml:"xmlns,attr,omitempty"`
HREF string `xml:"href,attr,omitempty"` // The URI of the entity.
Type string `xml:"type,attr,omitempty"` // The MIME type of the entity.
Link LinkList `xml:"Link,omitempty"` // A reference to an entity or operation associated with this object.
HREF string `xml:"href,attr,omitempty" json:"href,omitempty"` // The URI of the entity.
Type string `xml:"type,attr,omitempty" json:"type,omitempty"` // The MIME type of the entity.
Link LinkList `xml:"Link,omitempty" json:"link,omitempty"` // A reference to an entity or operation associated with this object.

OrgLdapMode string `xml:"OrgLdapMode,omitempty"` // LDAP mode you want
CustomUsersOu string `xml:"CustomUsersOu,omitempty"` // If OrgLdapMode is SYSTEM, specifies an LDAP attribute=value pair to use for OU (organizational unit).
CustomOrgLdapSettings *CustomOrgLdapSettings `xml:"CustomOrgLdapSettings,omitempty"` // Needs to be set if user chooses custom mode
OrgLdapMode string `xml:"OrgLdapMode,omitempty" json:"orgLdapMode,omitempty"` // LDAP mode you want
CustomUsersOu string `xml:"CustomUsersOu,omitempty" json:"customUsersOu,omitempty"` // If OrgLdapMode is SYSTEM, specifies an LDAP attribute=value pair to use for OU (organizational unit).
CustomOrgLdapSettings *CustomOrgLdapSettings `xml:"CustomOrgLdapSettings,omitempty" json:"customOrgLdapSettings,omitempty"` // Needs to be set if user chooses custom mode
}

// CustomOrgLdapSettings represents the custom ldap settings for a VMware Cloud Director organization.
Expand All @@ -1132,19 +1132,19 @@ type CustomOrgLdapSettings struct {
Type string `xml:"type,attr,omitempty"` // The MIME type of the entity.
Link LinkList `xml:"Link,omitempty"` // A reference to an entity or operation associated with this object.

HostName string `xml:"HostName,omitempty"`
Port int `xml:"Port"`
IsSsl bool `xml:"IsSsl,omitempty"`
IsSslAcceptAll bool `xml:"IsSslAcceptAll,omitempty"`
SearchBase string `xml:"SearchBase,omitempty"`
Username string `xml:"UserName,omitempty"`
Password string `xml:"Password,omitempty"`
AuthenticationMechanism string `xml:"AuthenticationMechanism"`
IsGroupSearchBaseEnabled bool `xml:"IsGroupSearchBaseEnabled"`
GroupSearchBase string `xml:"GroupSearchBase,omitempty"`
ConnectorType string `xml:"ConnectorType"` // Defines LDAP service implementation type
UserAttributes *OrgLdapUserAttributes `xml:"UserAttributes"` // Defines how LDAP attributes are used when importing a user.
GroupAttributes *OrgLdapGroupAttributes `xml:"GroupAttributes"` // Defines how LDAP attributes are used when importing a group.
HostName string `xml:"HostName,omitempty" json:"hostName,omitempty"`
Port int `xml:"Port" json:"port,omitempty"`
IsSsl bool `xml:"IsSsl,omitempty" json:"isSsl,omitempty"`
IsSslAcceptAll bool `xml:"IsSslAcceptAll,omitempty" json:"isSslAcceptAll,omitempty"`
SearchBase string `xml:"SearchBase,omitempty" json:"searchBase,omitempty"`
Username string `xml:"UserName,omitempty" json:"userName,omitempty"`
Password string `xml:"Password,omitempty" json:"password,omitempty"`
AuthenticationMechanism string `xml:"AuthenticationMechanism" json:"authenticationMechanism,omitempty"`
IsGroupSearchBaseEnabled bool `xml:"IsGroupSearchBaseEnabled" json:"isGroupSearchBaseEnabled,omitempty"`
GroupSearchBase string `xml:"GroupSearchBase,omitempty" json:"groupSearchBase,omitempty"`
ConnectorType string `xml:"ConnectorType" json:"connectorType,omitempty"` // Defines LDAP service implementation type
UserAttributes *OrgLdapUserAttributes `xml:"UserAttributes" json:"userAttributes,omitempty"` // Defines how LDAP attributes are used when importing a user.
GroupAttributes *OrgLdapGroupAttributes `xml:"GroupAttributes" json:"groupAttributes,omitempty"` // Defines how LDAP attributes are used when importing a group.
UseExternalKerberos bool `xml:"UseExternalKerberos"`

Realm string `xml:"Realm,omitempty"`
Expand All @@ -1157,12 +1157,12 @@ type CustomOrgLdapSettings struct {
// Since: 0.9
// Note. Order of these fields matter and API will error if it is changed
type OrgLdapGroupAttributes struct {
ObjectClass string `xml:"ObjectClass"`
ObjectIdentifier string `xml:"ObjectIdentifier"`
GroupName string `xml:"GroupName"`
Membership string `xml:"Membership"`
MembershipIdentifier string `xml:"MembershipIdentifier"`
BackLinkIdentifier string `xml:"BackLinkIdentifier,omitempty"`
ObjectClass string `xml:"ObjectClass" json:"objectClass"`
ObjectIdentifier string `xml:"ObjectIdentifier" json:"objectIdentifier"`
GroupName string `xml:"GroupName" json:"groupName"`
Membership string `xml:"Membership" json:"membership"`
MembershipIdentifier string `xml:"MembershipIdentifier" json:"membershipIdentifier"`
BackLinkIdentifier string `xml:"BackLinkIdentifier,omitempty" json:"backLinkIdentifier"`
}

// OrgLdapUserAttributesType represents the ldap user attribute settings for a VMware Cloud Director organization.
Expand All @@ -1172,16 +1172,16 @@ type OrgLdapGroupAttributes struct {
// Since: 0.9
// Note. Order of these fields matter and API will error if it is changed.
type OrgLdapUserAttributes struct {
ObjectClass string `xml:"ObjectClass"`
ObjectIdentifier string `xml:"ObjectIdentifier"`
Username string `xml:"UserName,omitempty"`
Email string `xml:"Email"`
FullName string `xml:"FullName"`
GivenName string `xml:"GivenName"`
Surname string `xml:"Surname"`
Telephone string `xml:"Telephone"`
GroupMembershipIdentifier string `xml:"GroupMembershipIdentifier"`
GroupBackLinkIdentifier string `xml:"GroupBackLinkIdentifier,omitempty"`
ObjectClass string `xml:"ObjectClass" json:"objectClass"`
ObjectIdentifier string `xml:"ObjectIdentifier" json:"objectIdentifier"`
Username string `xml:"UserName,omitempty" json:"userName"`
Email string `xml:"Email" json:"email"`
FullName string `xml:"FullName" json:"fullName"`
GivenName string `xml:"GivenName" json:"givenName"`
Surname string `xml:"Surname" json:"surname"`
Telephone string `xml:"Telephone" json:"telephone"`
GroupMembershipIdentifier string `xml:"GroupMembershipIdentifier" json:"groupMembershipIdentifier"`
GroupBackLinkIdentifier string `xml:"GroupBackLinkIdentifier,omitempty" json:"groupBackLinkIdentifier"`
}

// OrgPasswordPolicySettings represents password policy settings for this organization.
Expand Down

0 comments on commit 3214e60

Please sign in to comment.