Documentation ¶
Index ¶
- Constants
- func CheckAttributes(LdapConnection *ldap.Conn, LdapEntry, ADEntry *ldap.AddRequest)
- func CheckForError(e error)
- func CheckPerm(filename string)
- func ConnectToDirectoryServer(Host, Port string, Username, Password string, ConnTimeout int) *ldap.Conn
- func ConnectToDirectoryServerTLS(Host, Port string, Username, Password string, ConnTimeout int, ...) *ldap.Conn
- func ConvertAttributesToLower(upperAttribute *[]string) *[]string
- func ConvertRealmToLower(upperrealm []*ldap.AddRequest)
- func FindAdds(ADElementsConverted, LDAPElementsConverted *[]*ldap.AddRequest, ...)
- func FindDels(LDAPElementsConverted, ADElementsConverted *[]*ldap.AddRequest, ...)
- func GetFromAD(connect *ldap.Conn, ADBaseDN, ADFilter string, ADAttribute []string, ...) *[]LDAPElement
- func GetFromLDAP(connect *ldap.Conn, LDAPBaseDN, LDAPFilter string, LDAPAttribute []string, ...) *[]LDAPElement
- func IfDNExists(checkfor *ldap.AddRequest, checkin []*ldap.AddRequest) (bool, *ldap.AddRequest)
- func InitialPopulateToLdap(ADElements *[]LDAPElement, connectLDAP *ldap.Conn, ...) []*ldap.AddRequest
- func LoggerClose()
- func SetLogLevel(loglevel *string)
- func StartLog(logfile string) *log.Logger
- func StringInSlice(checkfor string, checkin []string) bool
- func SyncRunAD(ADHost, ADPort, ADUsername, ADPassword, ADBaseDN, ADFilter string, ...)
- func SyncRunLDAP(LDAPHost, LDAPPort, LDAPUsername, LDAPPassword, LDAPBaseDN, LDAPFilter string, ...)
- type Action
- type AddRequest
- type DS
- type LDAPElement
- type MapADandLDAP
- type RuntimeConfig
Constants ¶
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 ¶
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 StringInSlice ¶
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 ¶
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.