ldapper

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: MIT Imports: 6 Imported by: 0

README

ngr-ldapper

Lib for working with ldap

import (
    ldapper "github.com/NGRsoftlab/ngr-ldapper"
)

or (if you want ^^)

import (
    ldapCommon "github.com/NGRsoftlab/ngr-ldapper"
)

Documentation

Overview

Copyright 2020 NGR Softlab

Ldap_common - pack with common ldap functions (working with Active Directory).

ldap_common - pack with ldap functions (supports ldap and openLdap now (tls & noTls)).

creator: everyone using: ldapper "github.com/NGRsoftlab/ngr-ldapper"

Index

Constants

View Source
const (
	// User search AD pattern
	SearchFilterUserAd = "(userPrincipalName=%s*)"
	// User search openLdap pattern
	SearchFilterUserLinux = "(|(&(objectClass=person)(cn=%s))(structuralObjectClass=organizationalRole))"
	// department pattern
	FilterGroup = "(&(objectClass=organizationalUnit))"
	// user obj in ou pattern
	FilterUserAd    = "(&(objectClass=User))"
	FilterUserLinux = "(&(objectClass=person))"
	// For get AD struct
	DepthOfLdapSearch = 4
)

Variables

This section is empty.

Functions

func RecursiveADSearch

func RecursiveADSearch(prevLevel *[]GroupInfo, userName, passWord, host string, port interface{}, useTls, openLdap bool,
	level int) *[]GroupInfo

func TestBaseDn

func TestBaseDn(userName, passWord, host string, port interface{}, baseDn string, useTls, openLdap bool) error

Test search in AD baseDn path.

func TryAccess

func TryAccess(userName, passWord, host string, port interface{}, useTls bool) error

Test auth in AD.

Types

type ADStruct

type ADStruct struct {
	AD []GroupInfo `json:"ad_map"`
}

Full AD struct.

func ReadAdStruct

func ReadAdStruct(userName, passWord, host string, port interface{},
	baseDn string, useTls, openLdap bool) (ADStruct, error)

Reading full AD structure.

type GroupInfo

type GroupInfo struct {
	Name  string      `json:"name"`
	DName string      `json:"distinguishedName"` // long department name
	Ou    string      `json:"ou"`
	Has   []GroupInfo `json:"has"` // list of subdirs (group children)
}

Department obj from AD struct.

func ReadRootGroups

func ReadRootGroups(userName, passWord, host string, port interface{},
	baseDn string, useTls, openLdap bool) ([]GroupInfo, error)

Reading root AD dirs (ou).

func ReadSubGroups

func ReadSubGroups(userName, passWord, grp string, level int, host string,
	port interface{}, useTls, openLdap bool) ([]GroupInfo, error)

Reading AD subDirs in grp.

type ImportInfo

type ImportInfo struct {
	Name       interface{} `json:"name"` // full name (= cn)
	Login      interface{} `json:"login"`
	Mail       interface{} `json:"mail"`
	Title      interface{} `json:"title"`
	Department interface{} `json:"department"`
}

Short info for showing.

func ReadGroupUsers

func ReadGroupUsers(userName, passWord, grp, host string, port interface{}, useTls,
	openLdap bool) ([]ImportInfo, error)

Reading all users from grp.

type LdapConn added in v1.0.6

type LdapConn struct {
	Connection *ldap.Conn
	// contains filtered or unexported fields
}

/////////////////////////////////////////////

func NewLdapConn

func NewLdapConn(userName, passWord, host string, port interface{}, useTls bool) (*LdapConn, error)

func (*LdapConn) Close added in v1.0.6

func (conn *LdapConn) Close()

type UserInfo

type UserInfo struct {
	CN         interface{} `json:"cn"` // full name
	Department interface{} `json:"department"`
	Mobile     interface{} `json:"mobile"`         // mobile phone
	Mail       interface{} `json:"mail"`           // email
	Title      interface{} `json:"title"`          // user title
	Photo      interface{} `json:"thumbnailPhoto"` // bad photo from AD

	Company interface{} `json:"company"`
	Address interface{} `json:"address"`
	City    interface{} `json:"city"`
	Index   interface{} `json:"index"`
	Country interface{} `json:"country"`
	Room    interface{} `json:"room"`
	Phone   interface{} `json:"phone"`
	Manager interface{} `json:"manager"`
}

User info from AD struct.

func ReadUserInfo

func ReadUserInfo(userName, domUser, domPassWord, host string,
	port interface{}, baseDn string, useTls, openLdap bool) (UserInfo, error)

Reading user info from AD.

Jump to

Keyboard shortcuts

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