syncer

package
v0.0.0-...-6c846e2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const SampleConfig = `` /* 2134-byte string literal not displayed */

SampleConfig is used to print a sample config to STDOUT with all the required fields.

Variables

This section is empty.

Functions

func CheckAttributes

func CheckAttributes(LdapConnection *ldap.Conn, LdapEntry, ADEntry *ldap.AddRequest)

CheckAttributes compares and evaluates the attributes from both servers and if it doesn't match, rewrites the slave's attribute with that of master's.

func CheckForError

func CheckForError(e error)

CheckForError is just a helper function to check for error and of not nil, logs the error and panic.

func CheckPerm

func CheckPerm(filename string)

CheckPerm checks permission of the passed filename(string) and panics if group or others have > read permissions.

func ConnectToDirectoryServer

func ConnectToDirectoryServer(Host, Port string, Username, Password string, ConnTimeout int) *ldap.Conn

ConnectToDirectoryServer will try to establish a connection to the directory server and return the connection object. This is an un-encrypted connection, and the data transferred will be human readable if checked with tcpdump eg: tcpdump -v -XX

func ConnectToDirectoryServerTLS

func ConnectToDirectoryServerTLS(Host, Port string, Username, Password string, ConnTimeout int, CRTInsecureSkipVerify bool,
	CRTValidFor, CRTPath string) *ldap.Conn

ConnectToDirectoryServerTLS will try to establish a tls encrypted connection to the directory server, and return the connection object. If the CRTInsecureSkipVerify is set to false, this function will read the pem file from CRTPath to add the certificates into a cert pool and use it as the Root CAs, and set the ServerName to which the certificate was issued for, from CRTValidFor.

func ConvertAttributesToLower

func ConvertAttributesToLower(upperAttribute *[]string) *[]string

ConvertAttributesToLower is a normalisation function. This is for the sake of LDAP

func ConvertRealmToLower

func ConvertRealmToLower(upperrealm []*ldap.AddRequest)

ConvertRealmToLower is a normalisation function for Windows Active Directory. This is required because the realm is returned capitalised in Active Directory, and needs to be normalised for the sake of LDAP.

func FindAdds

func FindAdds(ADElementsConverted, LDAPElementsConverted *[]*ldap.AddRequest, LdapConnection *ldap.Conn, AddChan chan Action, shutdownAddChan chan string)

FindAdds function is used to find the entries that needs to be modified/added to the slave

func FindDels

func FindDels(LDAPElementsConverted, ADElementsConverted *[]*ldap.AddRequest, DelChan chan Action, shutdownDelChan chan string)

FindDels function is used to find the entries that needs to be deleted from the slave

func GetFromAD

func GetFromAD(connect *ldap.Conn, ADBaseDN, ADFilter string, ADAttribute []string, ADPage uint32) *[]LDAPElement

GetFromAD retrives values from AD / Master.

func GetFromLDAP

func GetFromLDAP(connect *ldap.Conn, LDAPBaseDN, LDAPFilter string, LDAPAttribute []string, LDAPPage uint32) *[]LDAPElement

GetFromLDAP retrives values from LDAP / Slave.

func IfDNExists

func IfDNExists(checkfor *ldap.AddRequest, checkin []*ldap.AddRequest) (bool, *ldap.AddRequest)

IfDNExists is used to evaluate if the DN exists in all the AddRequest.

func InitialPopulateToLdap

func InitialPopulateToLdap(ADElements *[]LDAPElement, connectLDAP *ldap.Conn,
	ReplaceAttributes, MapAttributes *ini.Section, ReturnData bool) []*ldap.AddRequest

InitialPopulateToLdap is a wrapper function on top of other functions in this same package.

func LoggerClose

func LoggerClose()

LoggerClose closes the logger fd.

func SetLogLevel

func SetLogLevel(loglevel *string)

SetLogLevel sets the loglevel.

func StartLog

func StartLog(logfile string) *log.Logger

StartLog starts the logger. Accepts a path to the logfile.

func StringInSlice

func StringInSlice(checkfor string, checkin []string) bool

StringInSlice is a helper function to check if a string exists in a given slice.

func SyncRunAD

func SyncRunAD(ADHost, ADPort, ADUsername, ADPassword, ADBaseDN, ADFilter string, ADAttribute []string,
	ADPage int, ADConnTimeout int, UseTLS bool, InsecureSkipVerify bool, CRTValidFor, ADCrtPath string, shutdownChannel chan string, ADElementsChan chan *[]LDAPElement)

SyncRunAD connects to AD for sync and writes the retrieved AD elements to the channel.

func SyncRunLDAP

func SyncRunLDAP(LDAPHost, LDAPPort, LDAPUsername, LDAPPassword, LDAPBaseDN, LDAPFilter string, LDAPAttribute []string,
	LDAPPage int, LDAPConnTimeout int, LDAPUseTLS bool, LDAPCRTInsecureSkipVerify bool, LDAPCrtValidFor string,
	LDAPCrtPath string, shutdownChannel chan string, LDAPElementsChan chan *[]LDAPElement,
	LdapConnectionChan chan *ldap.Conn, ReplaceAttributes, MapAttributes *ini.Section)

SyncRunLDAP connects to LDAP for sync, and writes the processed elements to channel.

Types

type Action

type Action map[string]*ldap.AddRequest

Action map is a lame attempt to define if the action needs to be an Add or a Delete

type AddRequest

type AddRequest struct {
	*ldap.AddRequest
}

AddRequest is a wrapperStruct to embed *ldap.AddRequest and add a custom method to it.

func (*AddRequest) SetDN

func (a *AddRequest) SetDN(dn string)

SetDN is used to set the Dn in an AddRequest

type DS

type DS struct {
	Host, Port, CRTValidFor, CRTPath, Username, Password,
	BaseDN, Filter string
	UseTLS, CRTInsecureSkipVerify bool
	Page, ConnTimeOut             int
	Attributes                    []string
}

DS is used to store the directory server config

type LDAPElement

type LDAPElement struct {
	DN string
	// contains filtered or unexported fields
}

LDAPElement holds the DN and attributes of an LDAP/AD entry.

type MapADandLDAP

type MapADandLDAP map[string][]string

MapADandLDAP (It is a wrong name for this variable) is a map of attribute type and its values.

type RuntimeConfig

type RuntimeConfig struct {
	//	From Server section
	ADServer                         DS
	LDAPServer                       DS
	ReplaceAttributes, MapAttributes *ini.Section
	Delay                            int
	LogLevel                         string
}

RuntimeConfig stores the parsed ini config from file as a struct.

func NewRuntimeConfig

func NewRuntimeConfig(path string) *RuntimeConfig

NewRuntimeConfig is used to return a RuntimeConfig struct. This is populated by reading the server's configuration ini file (default: /etc/ldapsync.ini) and parsing it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL