package util import ( "fmt" "github.rackspace.com/gorax/clients/eDir" ) var allowedGroups = []string{"ldap_netsec_torq"} // EDirValidation function validates that the passed in user value exists within // one of the pre-defined user groups. func EDirValidation(user string) error { u, err := eDir.GeteDirGroups(user) if err != nil { return err } for _, allowedGroup := range allowedGroups { for _, uGroup := range u[0].Groups { if uGroup == allowedGroup { return nil } } } return fmt.Errorf("User %v is not in the correct ldap group to make changes. Only codeuploads allowed.", user) }