ldapuserdetails

package
v0.0.0-...-bc05beb Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2014 License: MIT Imports: 6 Imported by: 0

README

Revel LDAP user details Filter

Simple Filter that gets details about user from LDAP.

Usage

init.go:

import (
    "github.com/mikkolehtisalo/ldapuserdetails"
)
    revel.Filters = []revel.Filter{
        ldapuserdetails.UserDetailsLoadFilter,     // Load user details from LDAP
    }

app.conf:

ldap.server=freeipa.localdomain
ldap.port=389
ldap.base=cn=users,cn=accounts,dc=localdomain
ldap.user_filter=(&(uid=*)(objectClass=inetUser))
ldap.user_uid_attr=uid
ldap.user_cn_attr=cn
ldap.user_photo_attr=photo;binary
ldap.user_group_attr=memberOf
ldap.group_filter=(&(cn=*)(objectClass=groupOfNames))
ldap.group_attributes=cn,member
ldap.user=uid=admin,cn=users,cn=accounts,dc=localdomain
ldap.passwd=password

The details can be accessed from struct

type User_details struct {
    Username string
    Visiblename string
    Photo []byte
    Groups []string
    Roles []string
}

that will be saved into c.Args["user_details"]. Type assertion .(ldapuserdetails.User_details) is usually required.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get_connection

func Get_connection() *ldap.Conn

Gets new LDAP connection. Must be Close()d later!

func QueryLdap

func QueryLdap(base string, filter string, attributes []string) *ldap.SearchResult

Performs basic query

func UserDetailsLoadFilter

func UserDetailsLoadFilter(c *revel.Controller, fc []revel.Filter)

Filter that loads the user's LDAP groups

Types

type User_details

type User_details struct {
	Username    string
	Visiblename string
	Photo       []byte
	Groups      []string
	Roles       []string
}

Struct for holding details about user

func Build_user_details

func Build_user_details(entry *ldap.Entry) User_details

Build the struct from LDAP search result

func Get_user_details

func Get_user_details(username string) User_details

Retrieve user details from LDAP

Jump to

Keyboard shortcuts

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