pax_global_header 0000666 0000000 0000000 00000000064 11766376717 0014537 g ustar 00root root 0000000 0000000 52 comment=2c1229f16c091731319ae22789ba10da9b2b6f25
golang-openldap-0.2/ 0000775 0000000 0000000 00000000000 11766376717 0014447 5 ustar 00root root 0000000 0000000 golang-openldap-0.2/README 0000664 0000000 0000000 00000006666 11766376717 0015345 0 ustar 00root root 0000000 0000000 OpenLDAP binding in GO Language.
INSTALL:
go get github.com/mqu/openldap
DONE :
func Initialize(url string) (*Ldap, error)
func (self *Ldap) Add(dn string, attrs map[string][]string) (error)
func (self *Ldap) Bind(who, cred string) error
func (self *Ldap) Close() error
func (self *Ldap) Unbind() error
func (self *Ldap) Result() (*LdapMessage, error)
func (self *Ldap) Search(base string, scope int, filter string, attributes []string) (*LdapMessage, error)
func (self *Ldap) SearchAll(base string, scope int, filter string, attributes []string) (*LdapSearchResult, error)
func (self *Ldap) Errno() int
func (self *Ldap) SetOption(opt int, val int) error
func (self *Ldap) GetOption(opt int) (val int, err error)
func (self *Ldap) IsThreadSafe() bool
func (self *Ldap) Delete(dn string) (error)
func (self *Ldap) ModifyAdd(dn string, attrs map[string][]string) (error)
func (self *Ldap) ModifyDel(dn string, attrs map[string][]string) (error)
func (self *Ldap) Modify(dn string, attrs map[string][]string) (error)
func (self *Ldap) Rename(dn string, newrdn string, newSuperior string, deleteOld bool) (error)
func (self *LdapMessage) Count() int
func (self *LdapMessage) FirstEntry() *LdapEntry
func (self *LdapMessage) FirstMessage() *LdapMessage
func (self *LdapMessage) GetAll() error
func (self *LdapMessage) MsgFree() int
func (self *LdapMessage) NextMessage() *LdapMessage
func (self *LdapSearchResult) Append(e LdapEntry)
func (self *LdapSearchResult) Attributes() []string
func (self *LdapSearchResult) Base() string
func (self *LdapSearchResult) Count() int
func (self *LdapSearchResult) Entries() []LdapEntry
func (self *LdapSearchResult) Filter() string
func (self *LdapSearchResult) Scope() int
func (self *LdapSearchResult) String() string
func (self *LdapSearchResult) ToText() string
func (self *LdapEntry) Append(a LdapAttribute)
func (self *LdapEntry) Attributes() []LdapAttribute
func (self *LdapEntry) CountEntries() int
func (self *LdapEntry) Dn() string
func (self *LdapEntry) FirstAttribute() (string, error)
func (self *LdapEntry) GetDn() string
func (self *LdapEntry) GetValues(attr string) []string
func (self *LdapEntry) NextAttribute() (string, error)
func (self *LdapEntry) NextEntry() *LdapEntry
func (self *LdapEntry) String() string
func (self *LdapEntry) ToText() string
func (self *LdapAttribute) Name() string
func (self *LdapAttribute) Values() []string
func (self *LdapAttribute) String() string
func (self *LdapAttribute) ToText() string
- to update this list : grep "^func" *.go | sed -e "s#^.*:##" | sort
Defined types :
- Ldap : handles LDAP connexion : Initialize, Bind, Close, Search, SearchAll
- LdapMessage : handles LDAP response from queries : Result, Search,
- LdapEntry : handles LDAP entry responses.
- LdapAttribute : handles LDAP entry responses.
- LdapResult : handle results and operations ()
TODO :
- support binary values ! Search() for "all attributes" will segfault (panic: runtime error: invalid memory address)
on binary attributes.
- thread-safe test
- complete LDAP:GetOption and LDAP:SetOption method : now, they work only for integer values.
- avoid using deprecated function (see LDAP_DEPRECATED flag)
- ...
look at _examples/test-openldap.go to see how to use this library.
LINKS :
- goc : http://code.google.com/p/go-wiki/wiki/cgo (how to bind native libraries to GO)
- Openldap library (and server) : http://www.openldap.org/
golang-openldap-0.2/README.md 0000664 0000000 0000000 00000003335 11766376717 0015732 0 ustar 00root root 0000000 0000000 OpenLDAP
====
this is Openldap binding in GO language.
Installation :
-----
Installation is easy and very quick, as you can see :
# install openldap library and devel packages
sudo apt-get install libldap libldap2-dev # debian/ubuntu.
sudo urpmi openldap-devel # fedora, RH, ...
# install go
go get github.com/mqu/openldap
# verify you've got it :
(cd $GOPATH ; go list ./...) | grep openldap
Usage
----
- Look a this [exemple](https://github.com/mqu/openldap/blob/master/_examples/test-openldap.go).
- a more complex example making [LDAP search](https://github.com/mqu/openldap/blob/master/_examples/ldapsearch.go) that mimics ldapsearch command, printing out result on console.
Doc:
---
- run _go doc openldap_,
- will come soon, complete documentation in this [Wiki](https://github.com/mqu/openldap/wiki).
- look at [_examples/](https://github.com/mqu/openldap/blob/master/_examples/)*.go to see how to use this library.
Todo :
----
- thread-safe test,
- complete LDAP:GetOption() and LDAP:SetOption() method : now, they work only for integer values,
- avoid using deprecated function (see LDAP_DEPRECATED flag and "// DEPRECATED" comments in *.go sources),
- write some tests,
- verify memory leaks (Valgrind),
- support LDIF format (in, out),
- add support for external commands (ldapadd, ldapdelete)
- create an LDAP CLI (command line interface), like lftp, with commands like shell,
- a nice GUI with GTK,
- proxy, server,
- what else ?
Link :
---
- goc : http://code.google.com/p/go-wiki/wiki/cgo (how to bind native libraries to GO)
- Openldap library (and server) : http://www.openldap.org/
- Pure Go [LDAP](https://github.com/mmitton/ldap) library, with [ASN1](https://github.com/mmitton/asn1-ber) support.
golang-openldap-0.2/_docs/ 0000775 0000000 0000000 00000000000 11766376717 0015536 5 ustar 00root root 0000000 0000000 golang-openldap-0.2/_docs/include/ 0000775 0000000 0000000 00000000000 11766376717 0017161 5 ustar 00root root 0000000 0000000 golang-openldap-0.2/_docs/include/lber.h 0000664 0000000 0000000 00000035717 11766376717 0020273 0 ustar 00root root 0000000 0000000 /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
* Copyright 1998-2012 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* .
*/
/* Portions Copyright (c) 1990 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
#ifndef _LBER_H
#define _LBER_H
#include
#include
LDAP_BEGIN_DECL
/*
* ber_tag_t represents the identifier octets at the beginning of BER
* elements. OpenLDAP treats them as mere big-endian unsigned integers.
*
* Actually the BER identifier octets look like this:
*
* Bits of 1st octet:
* ______
* 8 7 | CLASS
* 0 0 = UNIVERSAL
* 0 1 = APPLICATION
* 1 0 = CONTEXT-SPECIFIC
* 1 1 = PRIVATE
* _____
* | 6 | DATA-TYPE
* 0 = PRIMITIVE
* 1 = CONSTRUCTED
* ___________
* | 5 ... 1 | TAG-NUMBER
*
* For ASN.1 tag numbers >= 0x1F, TAG-NUMBER above is 0x1F and the next
* BER octets contain the actual ASN.1 tag number: Big-endian, base
* 128, 8.bit = 1 in all but the last octet, minimum number of octets.
*/
/* BER classes and mask (in 1st identifier octet) */
#define LBER_CLASS_UNIVERSAL ((ber_tag_t) 0x00U)
#define LBER_CLASS_APPLICATION ((ber_tag_t) 0x40U)
#define LBER_CLASS_CONTEXT ((ber_tag_t) 0x80U)
#define LBER_CLASS_PRIVATE ((ber_tag_t) 0xc0U)
#define LBER_CLASS_MASK ((ber_tag_t) 0xc0U)
/* BER encoding type and mask (in 1st identifier octet) */
#define LBER_PRIMITIVE ((ber_tag_t) 0x00U)
#define LBER_CONSTRUCTED ((ber_tag_t) 0x20U)
#define LBER_ENCODING_MASK ((ber_tag_t) 0x20U)
#define LBER_BIG_TAG_MASK ((ber_tag_t) 0x1fU)
#define LBER_MORE_TAG_MASK ((ber_tag_t) 0x80U)
/*
* LBER_ERROR and LBER_DEFAULT are values that can never appear
* as valid BER tags, so it is safe to use them to report errors.
* Valid tags have (tag & (ber_tag_t) 0xFF) != 0xFF.
*/
#define LBER_ERROR ((ber_tag_t) -1)
#define LBER_DEFAULT ((ber_tag_t) -1)
/* general BER types we know about */
#define LBER_BOOLEAN ((ber_tag_t) 0x01UL)
#define LBER_INTEGER ((ber_tag_t) 0x02UL)
#define LBER_BITSTRING ((ber_tag_t) 0x03UL)
#define LBER_OCTETSTRING ((ber_tag_t) 0x04UL)
#define LBER_NULL ((ber_tag_t) 0x05UL)
#define LBER_ENUMERATED ((ber_tag_t) 0x0aUL)
#define LBER_SEQUENCE ((ber_tag_t) 0x30UL) /* constructed */
#define LBER_SET ((ber_tag_t) 0x31UL) /* constructed */
/* LBER BerElement options */
#define LBER_USE_DER 0x01
/* get/set options for BerElement */
#define LBER_OPT_BER_OPTIONS 0x01
#define LBER_OPT_BER_DEBUG 0x02
#define LBER_OPT_BER_REMAINING_BYTES 0x03
#define LBER_OPT_BER_TOTAL_BYTES 0x04
#define LBER_OPT_BER_BYTES_TO_WRITE 0x05
#define LBER_OPT_BER_MEMCTX 0x06
#define LBER_OPT_DEBUG_LEVEL LBER_OPT_BER_DEBUG
#define LBER_OPT_REMAINING_BYTES LBER_OPT_BER_REMAINING_BYTES
#define LBER_OPT_TOTAL_BYTES LBER_OPT_BER_TOTAL_BYTES
#define LBER_OPT_BYTES_TO_WRITE LBER_OPT_BER_BYTES_TO_WRITE
#define LBER_OPT_LOG_PRINT_FN 0x8001
#define LBER_OPT_MEMORY_FNS 0x8002
#define LBER_OPT_ERROR_FN 0x8003
#define LBER_OPT_LOG_PRINT_FILE 0x8004
/* get/set Memory Debug options */
#define LBER_OPT_MEMORY_INUSE 0x8005 /* for memory debugging */
#define LBER_OPT_LOG_PROC 0x8006 /* for external logging function */
typedef int* (*BER_ERRNO_FN) LDAP_P(( void ));
typedef void (*BER_LOG_PRINT_FN) LDAP_P(( LDAP_CONST char *buf ));
typedef void* (BER_MEMALLOC_FN) LDAP_P(( ber_len_t size, void *ctx ));
typedef void* (BER_MEMCALLOC_FN) LDAP_P(( ber_len_t n, ber_len_t size, void *ctx ));
typedef void* (BER_MEMREALLOC_FN) LDAP_P(( void *p, ber_len_t size, void *ctx ));
typedef void (BER_MEMFREE_FN) LDAP_P(( void *p, void *ctx ));
typedef struct lber_memory_fns {
BER_MEMALLOC_FN *bmf_malloc;
BER_MEMCALLOC_FN *bmf_calloc;
BER_MEMREALLOC_FN *bmf_realloc;
BER_MEMFREE_FN *bmf_free;
} BerMemoryFunctions;
/* LBER Sockbuf_IO options */
#define LBER_SB_OPT_GET_FD 1
#define LBER_SB_OPT_SET_FD 2
#define LBER_SB_OPT_HAS_IO 3
#define LBER_SB_OPT_SET_NONBLOCK 4
#define LBER_SB_OPT_GET_SSL 7
#define LBER_SB_OPT_DATA_READY 8
#define LBER_SB_OPT_SET_READAHEAD 9
#define LBER_SB_OPT_DRAIN 10
#define LBER_SB_OPT_NEEDS_READ 11
#define LBER_SB_OPT_NEEDS_WRITE 12
#define LBER_SB_OPT_GET_MAX_INCOMING 13
#define LBER_SB_OPT_SET_MAX_INCOMING 14
/* Only meaningful ifdef LDAP_PF_LOCAL_SENDMSG */
#define LBER_SB_OPT_UNGET_BUF 15
/* Largest option used by the library */
#define LBER_SB_OPT_OPT_MAX 15
/* LBER IO operations stacking levels */
#define LBER_SBIOD_LEVEL_PROVIDER 10
#define LBER_SBIOD_LEVEL_TRANSPORT 20
#define LBER_SBIOD_LEVEL_APPLICATION 30
/* get/set options for Sockbuf */
#define LBER_OPT_SOCKBUF_DESC 0x1000
#define LBER_OPT_SOCKBUF_OPTIONS 0x1001
#define LBER_OPT_SOCKBUF_DEBUG 0x1002
/* on/off values */
LBER_V( char ) ber_pvt_opt_on;
#define LBER_OPT_ON ((void *) &ber_pvt_opt_on)
#define LBER_OPT_OFF ((void *) 0)
#define LBER_OPT_SUCCESS (0)
#define LBER_OPT_ERROR (-1)
typedef struct berelement BerElement;
typedef struct sockbuf Sockbuf;
typedef struct sockbuf_io Sockbuf_IO;
/* Structure for LBER IO operarion descriptor */
typedef struct sockbuf_io_desc {
int sbiod_level;
Sockbuf *sbiod_sb;
Sockbuf_IO *sbiod_io;
void *sbiod_pvt;
struct sockbuf_io_desc *sbiod_next;
} Sockbuf_IO_Desc;
/* Structure for LBER IO operation functions */
struct sockbuf_io {
int (*sbi_setup)( Sockbuf_IO_Desc *sbiod, void *arg );
int (*sbi_remove)( Sockbuf_IO_Desc *sbiod );
int (*sbi_ctrl)( Sockbuf_IO_Desc *sbiod, int opt, void *arg);
ber_slen_t (*sbi_read)( Sockbuf_IO_Desc *sbiod, void *buf,
ber_len_t len );
ber_slen_t (*sbi_write)( Sockbuf_IO_Desc *sbiod, void *buf,
ber_len_t len );
int (*sbi_close)( Sockbuf_IO_Desc *sbiod );
};
/* Helper macros for LBER IO functions */
#define LBER_SBIOD_READ_NEXT( sbiod, buf, len ) \
( (sbiod)->sbiod_next->sbiod_io->sbi_read( (sbiod)->sbiod_next, \
buf, len ) )
#define LBER_SBIOD_WRITE_NEXT( sbiod, buf, len ) \
( (sbiod)->sbiod_next->sbiod_io->sbi_write( (sbiod)->sbiod_next, \
buf, len ) )
#define LBER_SBIOD_CTRL_NEXT( sbiod, opt, arg ) \
( (sbiod)->sbiod_next ? \
( (sbiod)->sbiod_next->sbiod_io->sbi_ctrl( \
(sbiod)->sbiod_next, opt, arg ) ) : 0 )
/* structure for returning a sequence of octet strings + length */
typedef struct berval {
ber_len_t bv_len;
char *bv_val;
} BerValue;
typedef BerValue *BerVarray; /* To distinguish from a single bv */
/* this should be moved to lber-int.h */
/*
* in bprint.c:
*/
LBER_F( void )
ber_error_print LDAP_P((
LDAP_CONST char *data ));
LBER_F( void )
ber_bprint LDAP_P((
LDAP_CONST char *data, ber_len_t len ));
LBER_F( void )
ber_dump LDAP_P((
BerElement *ber, int inout ));
/*
* in decode.c:
*/
typedef int (*BERDecodeCallback) LDAP_P((
BerElement *ber,
void *data,
int mode ));
LBER_F( ber_tag_t )
ber_get_tag LDAP_P((
BerElement *ber ));
LBER_F( ber_tag_t )
ber_skip_tag LDAP_P((
BerElement *ber,
ber_len_t *len ));
LBER_F( ber_tag_t )
ber_peek_tag LDAP_P((
BerElement *ber,
ber_len_t *len ));
LBER_F( ber_tag_t )
ber_skip_element LDAP_P((
BerElement *ber,
struct berval *bv ));
LBER_F( ber_tag_t )
ber_peek_element LDAP_P((
LDAP_CONST BerElement *ber,
struct berval *bv ));
LBER_F( ber_tag_t )
ber_get_int LDAP_P((
BerElement *ber,
ber_int_t *num ));
LBER_F( ber_tag_t )
ber_get_enum LDAP_P((
BerElement *ber,
ber_int_t *num ));
LBER_F( ber_tag_t )
ber_get_stringb LDAP_P((
BerElement *ber,
char *buf,
ber_len_t *len ));
#define LBER_BV_ALLOC 0x01 /* allocate/copy result, otherwise in-place */
#define LBER_BV_NOTERM 0x02 /* omit NUL-terminator if parsing in-place */
#define LBER_BV_STRING 0x04 /* fail if berval contains embedded \0 */
/* LBER_BV_STRING currently accepts a terminating \0 in the berval, because
* Active Directory sends that in at least the diagonsticMessage field.
*/
LBER_F( ber_tag_t )
ber_get_stringbv LDAP_P((
BerElement *ber,
struct berval *bv,
int options ));
LBER_F( ber_tag_t )
ber_get_stringa LDAP_P((
BerElement *ber,
char **buf ));
LBER_F( ber_tag_t )
ber_get_stringal LDAP_P((
BerElement *ber,
struct berval **bv ));
LBER_F( ber_tag_t )
ber_get_bitstringa LDAP_P((
BerElement *ber,
char **buf,
ber_len_t *len ));
LBER_F( ber_tag_t )
ber_get_null LDAP_P((
BerElement *ber ));
LBER_F( ber_tag_t )
ber_get_boolean LDAP_P((
BerElement *ber,
ber_int_t *boolval ));
LBER_F( ber_tag_t )
ber_first_element LDAP_P((
BerElement *ber,
ber_len_t *len,
char **last ));
LBER_F( ber_tag_t )
ber_next_element LDAP_P((
BerElement *ber,
ber_len_t *len,
LDAP_CONST char *last ));
LBER_F( ber_tag_t )
ber_scanf LDAP_P((
BerElement *ber,
LDAP_CONST char *fmt,
... ));
LBER_F( int )
ber_decode_oid LDAP_P((
struct berval *in,
struct berval *out ));
/*
* in encode.c
*/
LBER_F( int )
ber_encode_oid LDAP_P((
struct berval *in,
struct berval *out ));
typedef int (*BEREncodeCallback) LDAP_P((
BerElement *ber,
void *data ));
LBER_F( int )
ber_put_enum LDAP_P((
BerElement *ber,
ber_int_t num,
ber_tag_t tag ));
LBER_F( int )
ber_put_int LDAP_P((
BerElement *ber,
ber_int_t num,
ber_tag_t tag ));
LBER_F( int )
ber_put_ostring LDAP_P((
BerElement *ber,
LDAP_CONST char *str,
ber_len_t len,
ber_tag_t tag ));
LBER_F( int )
ber_put_berval LDAP_P((
BerElement *ber,
struct berval *bv,
ber_tag_t tag ));
LBER_F( int )
ber_put_string LDAP_P((
BerElement *ber,
LDAP_CONST char *str,
ber_tag_t tag ));
LBER_F( int )
ber_put_bitstring LDAP_P((
BerElement *ber,
LDAP_CONST char *str,
ber_len_t bitlen,
ber_tag_t tag ));
LBER_F( int )
ber_put_null LDAP_P((
BerElement *ber,
ber_tag_t tag ));
LBER_F( int )
ber_put_boolean LDAP_P((
BerElement *ber,
ber_int_t boolval,
ber_tag_t tag ));
LBER_F( int )
ber_start_seq LDAP_P((
BerElement *ber,
ber_tag_t tag ));
LBER_F( int )
ber_start_set LDAP_P((
BerElement *ber,
ber_tag_t tag ));
LBER_F( int )
ber_put_seq LDAP_P((
BerElement *ber ));
LBER_F( int )
ber_put_set LDAP_P((
BerElement *ber ));
LBER_F( int )
ber_printf LDAP_P((
BerElement *ber,
LDAP_CONST char *fmt,
... ));
/*
* in io.c:
*/
LBER_F( ber_slen_t )
ber_skip_data LDAP_P((
BerElement *ber,
ber_len_t len ));
LBER_F( ber_slen_t )
ber_read LDAP_P((
BerElement *ber,
char *buf,
ber_len_t len ));
LBER_F( ber_slen_t )
ber_write LDAP_P((
BerElement *ber,
LDAP_CONST char *buf,
ber_len_t len,
int zero )); /* nonzero is unsupported from OpenLDAP 2.4.18 */
LBER_F( void )
ber_free LDAP_P((
BerElement *ber,
int freebuf ));
LBER_F( void )
ber_free_buf LDAP_P(( BerElement *ber ));
LBER_F( int )
ber_flush2 LDAP_P((
Sockbuf *sb,
BerElement *ber,
int freeit ));
#define LBER_FLUSH_FREE_NEVER (0x0) /* traditional behavior */
#define LBER_FLUSH_FREE_ON_SUCCESS (0x1) /* traditional behavior */
#define LBER_FLUSH_FREE_ON_ERROR (0x2)
#define LBER_FLUSH_FREE_ALWAYS (LBER_FLUSH_FREE_ON_SUCCESS|LBER_FLUSH_FREE_ON_ERROR)
LBER_F( int )
ber_flush LDAP_P((
Sockbuf *sb,
BerElement *ber,
int freeit )); /* DEPRECATED */
LBER_F( BerElement * )
ber_alloc LDAP_P(( void )); /* DEPRECATED */
LBER_F( BerElement * )
der_alloc LDAP_P(( void )); /* DEPRECATED */
LBER_F( BerElement * )
ber_alloc_t LDAP_P((
int beroptions ));
LBER_F( BerElement * )
ber_dup LDAP_P((
BerElement *ber ));
LBER_F( ber_tag_t )
ber_get_next LDAP_P((
Sockbuf *sb,
ber_len_t *len,
BerElement *ber ));
LBER_F( void )
ber_init2 LDAP_P((
BerElement *ber,
struct berval *bv,
int options ));
LBER_F( void )
ber_init_w_nullc LDAP_P(( /* DEPRECATED */
BerElement *ber,
int options ));
LBER_F( void )
ber_reset LDAP_P((
BerElement *ber,
int was_writing ));
LBER_F( BerElement * )
ber_init LDAP_P((
struct berval *bv ));
LBER_F( int )
ber_flatten LDAP_P((
BerElement *ber,
struct berval **bvPtr ));
LBER_F( int )
ber_flatten2 LDAP_P((
BerElement *ber,
struct berval *bv,
int alloc ));
LBER_F( int )
ber_remaining LDAP_P((
BerElement *ber ));
/*
* LBER ber accessor functions
*/
LBER_F( int )
ber_get_option LDAP_P((
void *item,
int option,
void *outvalue));
LBER_F( int )
ber_set_option LDAP_P((
void *item,
int option,
LDAP_CONST void *invalue));
/*
* LBER sockbuf.c
*/
LBER_F( Sockbuf * )
ber_sockbuf_alloc LDAP_P((
void ));
LBER_F( void )
ber_sockbuf_free LDAP_P((
Sockbuf *sb ));
LBER_F( int )
ber_sockbuf_add_io LDAP_P((
Sockbuf *sb,
Sockbuf_IO *sbio,
int layer,
void *arg ));
LBER_F( int )
ber_sockbuf_remove_io LDAP_P((
Sockbuf *sb,
Sockbuf_IO *sbio,
int layer ));
LBER_F( int )
ber_sockbuf_ctrl LDAP_P((
Sockbuf *sb,
int opt,
void *arg ));
LBER_V( Sockbuf_IO ) ber_sockbuf_io_tcp;
LBER_V( Sockbuf_IO ) ber_sockbuf_io_readahead;
LBER_V( Sockbuf_IO ) ber_sockbuf_io_fd;
LBER_V( Sockbuf_IO ) ber_sockbuf_io_debug;
LBER_V( Sockbuf_IO ) ber_sockbuf_io_udp;
/*
* LBER memory.c
*/
LBER_F( void * )
ber_memalloc LDAP_P((
ber_len_t s ));
LBER_F( void * )
ber_memrealloc LDAP_P((
void* p,
ber_len_t s ));
LBER_F( void * )
ber_memcalloc LDAP_P((
ber_len_t n,
ber_len_t s ));
LBER_F( void )
ber_memfree LDAP_P((
void* p ));
LBER_F( void )
ber_memvfree LDAP_P((
void** vector ));
LBER_F( void )
ber_bvfree LDAP_P((
struct berval *bv ));
LBER_F( void )
ber_bvecfree LDAP_P((
struct berval **bv ));
LBER_F( int )
ber_bvecadd LDAP_P((
struct berval ***bvec,
struct berval *bv ));
LBER_F( struct berval * )
ber_dupbv LDAP_P((
struct berval *dst, struct berval *src ));
LBER_F( struct berval * )
ber_bvdup LDAP_P((
struct berval *src ));
LBER_F( struct berval * )
ber_mem2bv LDAP_P((
LDAP_CONST char *, ber_len_t len, int duplicate, struct berval *bv));
LBER_F( struct berval * )
ber_str2bv LDAP_P((
LDAP_CONST char *, ber_len_t len, int duplicate, struct berval *bv));
#define ber_bvstr(a) ((ber_str2bv)((a), 0, 0, NULL))
#define ber_bvstrdup(a) ((ber_str2bv)((a), 0, 1, NULL))
LBER_F( char * )
ber_strdup LDAP_P((
LDAP_CONST char * ));
LBER_F( ber_len_t )
ber_strnlen LDAP_P((
LDAP_CONST char *s, ber_len_t len ));
LBER_F( char * )
ber_strndup LDAP_P((
LDAP_CONST char *s, ber_len_t l ));
LBER_F( struct berval * )
ber_bvreplace LDAP_P((
struct berval *dst, LDAP_CONST struct berval *src ));
LBER_F( void )
ber_bvarray_free LDAP_P(( BerVarray p ));
LBER_F( int )
ber_bvarray_add LDAP_P(( BerVarray *p, BerValue *bv ));
#define ber_bvcmp(v1,v2) \
((v1)->bv_len < (v2)->bv_len \
? -1 : ((v1)->bv_len > (v2)->bv_len \
? 1 : memcmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) ))
/*
* error.c
*/
LBER_F( int * ) ber_errno_addr LDAP_P((void));
#define ber_errno (*(ber_errno_addr)())
#define LBER_ERROR_NONE 0
#define LBER_ERROR_PARAM 0x1
#define LBER_ERROR_MEMORY 0x2
LDAP_END_DECL
#endif /* _LBER_H */
golang-openldap-0.2/_docs/include/lber_types.h 0000664 0000000 0000000 00000002674 11766376717 0021513 0 ustar 00root root 0000000 0000000 /* include/lber_types.h. Generated from lber_types.hin by configure. */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
* Copyright 1998-2012 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* .
*/
/*
* LBER types
*/
#ifndef _LBER_TYPES_H
#define _LBER_TYPES_H
#include
LDAP_BEGIN_DECL
/* LBER boolean, enum, integers (32 bits or larger) */
#define LBER_INT_T int
/* LBER tags (32 bits or larger) */
#define LBER_TAG_T long
/* LBER socket descriptor */
#define LBER_SOCKET_T int
/* LBER lengths (32 bits or larger) */
#define LBER_LEN_T long
/* ------------------------------------------------------------ */
/* booleans, enumerations, and integers */
typedef LBER_INT_T ber_int_t;
/* signed and unsigned versions */
typedef signed LBER_INT_T ber_sint_t;
typedef unsigned LBER_INT_T ber_uint_t;
/* tags */
typedef unsigned LBER_TAG_T ber_tag_t;
/* "socket" descriptors */
typedef LBER_SOCKET_T ber_socket_t;
/* lengths */
typedef unsigned LBER_LEN_T ber_len_t;
/* signed lengths */
typedef signed LBER_LEN_T ber_slen_t;
LDAP_END_DECL
#endif /* _LBER_TYPES_H */
golang-openldap-0.2/_docs/include/ldap-search.c 0000664 0000000 0000000 00000021766 11766376717 0021524 0 ustar 00root root 0000000 0000000
static void
do_random( char *uri, char *manager, struct berval *passwd,
char *sbase, int scope, char *filter, char *attr,
char **srchattrs, int noattrs, int nobind,
int innerloop, int maxretries, int delay, int force, int chaserefs )
{
LDAP *ld = NULL;
int i = 0, do_retry = maxretries;
char *attrs[ 2 ];
int rc = LDAP_SUCCESS;
int version = LDAP_VERSION3;
int nvalues = 0;
char **values = NULL;
LDAPMessage *res = NULL, *e = NULL;
attrs[ 0 ] = attr;
attrs[ 1 ] = NULL;
ldap_initialize( &ld, uri );
if ( ld == NULL ) {
tester_perror( "ldap_initialize", NULL );
exit( EXIT_FAILURE );
}
(void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
(void) ldap_set_option( ld, LDAP_OPT_REFERRALS,
chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF );
if ( do_retry == maxretries ) {
fprintf( stderr, "PID=%ld - Search(%d): base=\"%s\", filter=\"%s\" attr=\"%s\".\n",
(long) pid, innerloop, sbase, filter, attr );
}
if ( nobind == 0 ) {
rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
switch ( rc ) {
case LDAP_BUSY:
case LDAP_UNAVAILABLE:
/* fallthru */
default:
break;
}
exit( EXIT_FAILURE );
}
}
rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE,
filter, attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res );
switch ( rc ) {
case LDAP_SIZELIMIT_EXCEEDED:
case LDAP_TIMELIMIT_EXCEEDED:
case LDAP_SUCCESS:
if ( ldap_count_entries( ld, res ) == 0 ) {
if ( rc ) {
tester_ldap_error( ld, "ldap_search_ext_s", NULL );
}
break;
}
for ( e = ldap_first_entry( ld, res ); e != NULL; e = ldap_next_entry( ld, e ) )
{
struct berval **v = ldap_get_values_len( ld, e, attr );
if ( v != NULL ) {
int n = ldap_count_values_len( v );
int j;
values = realloc( values, ( nvalues + n + 1 )*sizeof( char * ) );
for ( j = 0; j < n; j++ ) {
values[ nvalues + j ] = strdup( v[ j ]->bv_val );
}
values[ nvalues + j ] = NULL;
nvalues += n;
ldap_value_free_len( v );
}
}
ldap_msgfree( res );
if ( !values ) {
fprintf( stderr, " PID=%ld - Search base=\"%s\" filter=\"%s\" got %d values.\n",
(long) pid, sbase, filter, nvalues );
exit(EXIT_FAILURE);
}
if ( do_retry == maxretries ) {
fprintf( stderr, " PID=%ld - Search base=\"%s\" filter=\"%s\" got %d values.\n",
(long) pid, sbase, filter, nvalues );
}
for ( i = 0; i < innerloop; i++ ) {
char buf[ BUFSIZ ];
#if 0 /* use high-order bits for better randomness (Numerical Recipes in "C") */
int r = rand() % nvalues;
#endif
int r = ((double)nvalues)*rand()/(RAND_MAX + 1.0);
snprintf( buf, sizeof( buf ), "(%s=%s)", attr, values[ r ] );
do_search( uri, manager, passwd,
sbase, scope, buf, &ld,
srchattrs, noattrs, nobind,
1, maxretries, delay, force, chaserefs );
}
default:
tester_ldap_error( ld, "ldap_search_ext_s", NULL );
break;
}
fprintf( stderr, " PID=%ld - Search done (%d).\n", (long) pid, rc );
if ( ld != NULL ) {
ldap_unbind_ext( ld, NULL, NULL );
}
static void
print_search_entry( LDAP *ld, LDAPMessage *res )
{
LDAPMessage *e;
for ( e = ldap_first_entry( ld, res ); e != NULL;
e = ldap_next_entry( ld, e ) )
{
BerElement *ber = NULL;
char *a, *dn, *ufn;
if ( e->lm_msgtype == LDAP_RES_SEARCH_RESULT )
break;
dn = ldap_get_dn( ld, e );
printf( "\tDN: %s\n", dn );
ufn = ldap_dn2ufn( dn );
printf( "\tUFN: %s\n", ufn );
free( dn );
free( ufn );
for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL;
a = ldap_next_attribute( ld, e, ber ) )
{
struct berval **vals;
printf( "\t\tATTR: %s\n", a );
if ( (vals = ldap_get_values_len( ld, e, a )) == NULL ) {
printf( "\t\t\t(no values)\n" );
} else {
int i;
for ( i = 0; vals[i] != NULL; i++ ) {
int j, nonascii;
nonascii = 0;
for ( j = 0; (ber_len_t) j < vals[i]->bv_len; j++ )
if ( !isascii( vals[i]->bv_val[j] ) ) {
nonascii = 1;
break;
}
if ( nonascii ) {
printf( "\t\t\tlength (%ld) (not ascii)\n", vals[i]->bv_len );
#ifdef BPRINT_NONASCII
ber_bprint( vals[i]->bv_val,
vals[i]->bv_len );
#endif /* BPRINT_NONASCII */
continue;
}
printf( "\t\t\tlength (%ld) %s\n",
vals[i]->bv_len, vals[i]->bv_val );
}
ber_bvecfree( vals );
}
}
if(ber != NULL) {
ber_free( ber, 0 );
}
if ( res->lm_msgtype == LDAP_RES_SEARCH_RESULT
|| res->lm_chain != NULL )
print_ldap_result( ld, res, "search" );
}
for ( e = ldap_first_entry( ld, res ); e != NULL; e = ldap_next_entry( ld, e ) )
{
struct berval **v = ldap_get_values_len( ld, e, attr );
if ( v != NULL ) {
int n = ldap_count_values_len( v );
int j;
values = realloc( values, ( nvalues + n + 1 )*sizeof( char * ) );
for ( j = 0; j < n; j++ ) {
values[ nvalues + j ] = strdup( v[ j ]->bv_val );
}
values[ nvalues + j ] = NULL;
nvalues += n;
ldap_value_free_len( v );
}
}
---
#include
LDAP *ld;
LDAPMessage *e;
char *a="jpegPhoto";
struct berval **bvals;
int count;
...
/* Get the values of the jpegPhoto attribute */
bvals = ldap_get_values_len( ld, e, a );
/* Count the values of the attribute */
count = ldap_count_values_len( vals );
---------
for ( e = ldap_first_entry( ld, result ); e != NULL;
e = ldap_next_entry( ld, e ) )
{
if ( (sdn = ldap_get_dn( ld, e )) != NULL )
{
printf( "\tdn: %s\n", sdn );
ldap_memfree( sdn );
}
for ( a = ldap_first_attribute( ld, e, &ber );
a != NULL; a = ldap_next_attribute( ld, e, ber ) )
{
if ((vals = ldap_get_values( ld, e, a)) != NULL )
{
for ( j = 0; vals[j] != NULL; j++ )
{
printf( "\t%s: %s\n", a, vals[j] );
}
ldap_value_free( vals );
}
ldap_memfree(a);
}
ber_free(ber, 0);
}
ldap_msgfree( result );
golang-openldap-0.2/_docs/include/ldap.h 0000664 0000000 0000000 00000176347 11766376717 0020274 0 ustar 00root root 0000000 0000000 /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
* Copyright 1998-2012 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* .
*/
/* Portions Copyright (c) 1990 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
#ifndef _LDAP_H
#define _LDAP_H
/* pull in lber */
#include
/* include version and API feature defines */
#include
LDAP_BEGIN_DECL
#define LDAP_VERSION1 1
#define LDAP_VERSION2 2
#define LDAP_VERSION3 3
#define LDAP_VERSION_MIN LDAP_VERSION2
#define LDAP_VERSION LDAP_VERSION2
#define LDAP_VERSION_MAX LDAP_VERSION3
/*
* We use 3000+n here because it is above 1823 (for RFC 1823),
* above 2000+rev of IETF LDAPEXT draft (now quite dated),
* yet below allocations for new RFCs (just in case there is
* someday an RFC produced).
*/
#define LDAP_API_VERSION 3001
#define LDAP_VENDOR_NAME "OpenLDAP"
/* OpenLDAP API Features */
#define LDAP_API_FEATURE_X_OPENLDAP LDAP_VENDOR_VERSION
#if defined( LDAP_API_FEATURE_X_OPENLDAP_REENTRANT ) || \
( defined( LDAP_THREAD_SAFE ) && \
defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE ) )
/* -lldap may or may not be thread safe */
/* -lldap_r, if available, is always thread safe */
# define LDAP_API_FEATURE_THREAD_SAFE 1
# define LDAP_API_FEATURE_SESSION_THREAD_SAFE 1
# define LDAP_API_FEATURE_OPERATION_THREAD_SAFE 1
#endif
#if defined( LDAP_THREAD_SAFE ) && \
defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE )
/* #define LDAP_API_FEATURE_SESSION_SAFE 1 */
/* #define LDAP_API_OPERATION_SESSION_SAFE 1 */
#endif
#define LDAP_PORT 389 /* ldap:/// default LDAP port */
#define LDAPS_PORT 636 /* ldaps:/// default LDAP over TLS port */
#define LDAP_ROOT_DSE ""
#define LDAP_NO_ATTRS "1.1"
#define LDAP_ALL_USER_ATTRIBUTES "*"
#define LDAP_ALL_OPERATIONAL_ATTRIBUTES "+" /* RFC 3673 */
/* RFC 4511: maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) -- */
#define LDAP_MAXINT (2147483647)
/*
* LDAP_OPTions
* 0x0000 - 0x0fff reserved for api options
* 0x1000 - 0x3fff reserved for api extended options
* 0x4000 - 0x7fff reserved for private and experimental options
*/
#define LDAP_OPT_API_INFO 0x0000
#define LDAP_OPT_DESC 0x0001 /* historic */
#define LDAP_OPT_DEREF 0x0002
#define LDAP_OPT_SIZELIMIT 0x0003
#define LDAP_OPT_TIMELIMIT 0x0004
/* 0x05 - 0x07 not defined */
#define LDAP_OPT_REFERRALS 0x0008
#define LDAP_OPT_RESTART 0x0009
/* 0x0a - 0x10 not defined */
#define LDAP_OPT_PROTOCOL_VERSION 0x0011
#define LDAP_OPT_SERVER_CONTROLS 0x0012
#define LDAP_OPT_CLIENT_CONTROLS 0x0013
/* 0x14 not defined */
#define LDAP_OPT_API_FEATURE_INFO 0x0015
/* 0x16 - 0x2f not defined */
#define LDAP_OPT_HOST_NAME 0x0030
#define LDAP_OPT_RESULT_CODE 0x0031
#define LDAP_OPT_ERROR_NUMBER LDAP_OPT_RESULT_CODE
#define LDAP_OPT_DIAGNOSTIC_MESSAGE 0x0032
#define LDAP_OPT_ERROR_STRING LDAP_OPT_DIAGNOSTIC_MESSAGE
#define LDAP_OPT_MATCHED_DN 0x0033
/* 0x0034 - 0x3fff not defined */
/* 0x0091 used by Microsoft for LDAP_OPT_AUTO_RECONNECT */
#define LDAP_OPT_SSPI_FLAGS 0x0092
/* 0x0093 used by Microsoft for LDAP_OPT_SSL_INFO */
/* 0x0094 used by Microsoft for LDAP_OPT_REF_DEREF_CONN_PER_MSG */
#define LDAP_OPT_SIGN 0x0095
#define LDAP_OPT_ENCRYPT 0x0096
#define LDAP_OPT_SASL_METHOD 0x0097
/* 0x0098 used by Microsoft for LDAP_OPT_AREC_EXCLUSIVE */
#define LDAP_OPT_SECURITY_CONTEXT 0x0099
/* 0x009A used by Microsoft for LDAP_OPT_ROOTDSE_CACHE */
/* 0x009B - 0x3fff not defined */
/* API Extensions */
#define LDAP_OPT_API_EXTENSION_BASE 0x4000 /* API extensions */
/* private and experimental options */
/* OpenLDAP specific options */
#define LDAP_OPT_DEBUG_LEVEL 0x5001 /* debug level */
#define LDAP_OPT_TIMEOUT 0x5002 /* default timeout */
#define LDAP_OPT_REFHOPLIMIT 0x5003 /* ref hop limit */
#define LDAP_OPT_NETWORK_TIMEOUT 0x5005 /* socket level timeout */
#define LDAP_OPT_URI 0x5006
#define LDAP_OPT_REFERRAL_URLS 0x5007 /* Referral URLs */
#define LDAP_OPT_SOCKBUF 0x5008 /* sockbuf */
#define LDAP_OPT_DEFBASE 0x5009 /* searchbase */
#define LDAP_OPT_CONNECT_ASYNC 0x5010 /* create connections asynchronously */
#define LDAP_OPT_CONNECT_CB 0x5011 /* connection callbacks */
#define LDAP_OPT_SESSION_REFCNT 0x5012 /* session reference count */
/* OpenLDAP TLS options */
#define LDAP_OPT_X_TLS 0x6000
#define LDAP_OPT_X_TLS_CTX 0x6001 /* OpenSSL CTX* */
#define LDAP_OPT_X_TLS_CACERTFILE 0x6002
#define LDAP_OPT_X_TLS_CACERTDIR 0x6003
#define LDAP_OPT_X_TLS_CERTFILE 0x6004
#define LDAP_OPT_X_TLS_KEYFILE 0x6005
#define LDAP_OPT_X_TLS_REQUIRE_CERT 0x6006
#define LDAP_OPT_X_TLS_PROTOCOL_MIN 0x6007
#define LDAP_OPT_X_TLS_CIPHER_SUITE 0x6008
#define LDAP_OPT_X_TLS_RANDOM_FILE 0x6009
#define LDAP_OPT_X_TLS_SSL_CTX 0x600a /* OpenSSL SSL* */
#define LDAP_OPT_X_TLS_CRLCHECK 0x600b
#define LDAP_OPT_X_TLS_CONNECT_CB 0x600c
#define LDAP_OPT_X_TLS_CONNECT_ARG 0x600d
#define LDAP_OPT_X_TLS_DHFILE 0x600e
#define LDAP_OPT_X_TLS_NEWCTX 0x600f
#define LDAP_OPT_X_TLS_CRLFILE 0x6010 /* GNUtls only */
#define LDAP_OPT_X_TLS_PACKAGE 0x6011
#define LDAP_OPT_X_TLS_NEVER 0
#define LDAP_OPT_X_TLS_HARD 1
#define LDAP_OPT_X_TLS_DEMAND 2
#define LDAP_OPT_X_TLS_ALLOW 3
#define LDAP_OPT_X_TLS_TRY 4
#define LDAP_OPT_X_TLS_CRL_NONE 0
#define LDAP_OPT_X_TLS_CRL_PEER 1
#define LDAP_OPT_X_TLS_CRL_ALL 2
/* for LDAP_OPT_X_TLS_PROTOCOL_MIN */
#define LDAP_OPT_X_TLS_PROTOCOL(maj,min) (((maj) << 8) + (min))
#define LDAP_OPT_X_TLS_PROTOCOL_SSL2 (2 << 8)
#define LDAP_OPT_X_TLS_PROTOCOL_SSL3 (3 << 8)
#define LDAP_OPT_X_TLS_PROTOCOL_TLS1_0 ((3 << 8) + 1)
#define LDAP_OPT_X_TLS_PROTOCOL_TLS1_1 ((3 << 8) + 2)
#define LDAP_OPT_X_TLS_PROTOCOL_TLS1_2 ((3 << 8) + 3)
/* OpenLDAP SASL options */
#define LDAP_OPT_X_SASL_MECH 0x6100
#define LDAP_OPT_X_SASL_REALM 0x6101
#define LDAP_OPT_X_SASL_AUTHCID 0x6102
#define LDAP_OPT_X_SASL_AUTHZID 0x6103
#define LDAP_OPT_X_SASL_SSF 0x6104 /* read-only */
#define LDAP_OPT_X_SASL_SSF_EXTERNAL 0x6105 /* write-only */
#define LDAP_OPT_X_SASL_SECPROPS 0x6106 /* write-only */
#define LDAP_OPT_X_SASL_SSF_MIN 0x6107
#define LDAP_OPT_X_SASL_SSF_MAX 0x6108
#define LDAP_OPT_X_SASL_MAXBUFSIZE 0x6109
#define LDAP_OPT_X_SASL_MECHLIST 0x610a /* read-only */
#define LDAP_OPT_X_SASL_NOCANON 0x610b
#define LDAP_OPT_X_SASL_USERNAME 0x610c /* read-only */
#define LDAP_OPT_X_SASL_GSS_CREDS 0x610d
/* OpenLDAP GSSAPI options */
#define LDAP_OPT_X_GSSAPI_DO_NOT_FREE_CONTEXT 0x6200
#define LDAP_OPT_X_GSSAPI_ALLOW_REMOTE_PRINCIPAL 0x6201
/*
* OpenLDAP per connection tcp-keepalive settings
* (Linux only, ignored where unsupported)
*/
#define LDAP_OPT_X_KEEPALIVE_IDLE 0x6300
#define LDAP_OPT_X_KEEPALIVE_PROBES 0x6301
#define LDAP_OPT_X_KEEPALIVE_INTERVAL 0x6302
/* Private API Extensions -- reserved for application use */
#define LDAP_OPT_PRIVATE_EXTENSION_BASE 0x7000 /* Private API inclusive */
/*
* ldap_get_option() and ldap_set_option() return values.
* As later versions may return other values indicating
* failure, current applications should only compare returned
* value against LDAP_OPT_SUCCESS.
*/
#define LDAP_OPT_SUCCESS 0
#define LDAP_OPT_ERROR (-1)
/* option on/off values */
#define LDAP_OPT_ON ((void *) &ber_pvt_opt_on)
#define LDAP_OPT_OFF ((void *) 0)
typedef struct ldapapiinfo {
int ldapai_info_version; /* version of LDAPAPIInfo */
#define LDAP_API_INFO_VERSION (1)
int ldapai_api_version; /* revision of API supported */
int ldapai_protocol_version; /* highest LDAP version supported */
char **ldapai_extensions; /* names of API extensions */
char *ldapai_vendor_name; /* name of supplier */
int ldapai_vendor_version; /* supplier-specific version * 100 */
} LDAPAPIInfo;
typedef struct ldap_apifeature_info {
int ldapaif_info_version; /* version of LDAPAPIFeatureInfo */
#define LDAP_FEATURE_INFO_VERSION (1) /* apifeature_info struct version */
char* ldapaif_name; /* LDAP_API_FEATURE_* (less prefix) */
int ldapaif_version; /* value of LDAP_API_FEATURE_... */
} LDAPAPIFeatureInfo;
/*
* LDAP Control structure
*/
typedef struct ldapcontrol {
char * ldctl_oid; /* numericoid of control */
struct berval ldctl_value; /* encoded value of control */
char ldctl_iscritical; /* criticality */
} LDAPControl;
/* LDAP Controls */
/* standard track controls */
#define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2" /* RFC 3296 */
#define LDAP_CONTROL_PROXY_AUTHZ "2.16.840.1.113730.3.4.18" /* RFC 4370 */
#define LDAP_CONTROL_SUBENTRIES "1.3.6.1.4.1.4203.1.10.1" /* RFC 3672 */
#define LDAP_CONTROL_VALUESRETURNFILTER "1.2.826.0.1.3344810.2.3"/* RFC 3876 */
#define LDAP_CONTROL_ASSERT "1.3.6.1.1.12" /* RFC 4528 */
#define LDAP_CONTROL_PRE_READ "1.3.6.1.1.13.1" /* RFC 4527 */
#define LDAP_CONTROL_POST_READ "1.3.6.1.1.13.2" /* RFC 4527 */
#define LDAP_CONTROL_SORTREQUEST "1.2.840.113556.1.4.473" /* RFC 2891 */
#define LDAP_CONTROL_SORTRESPONSE "1.2.840.113556.1.4.474" /* RFC 2891 */
/* non-standard track controls */
#define LDAP_CONTROL_PAGEDRESULTS "1.2.840.113556.1.4.319" /* RFC 2696 */
/* LDAP Content Synchronization Operation -- RFC 4533 */
#define LDAP_SYNC_OID "1.3.6.1.4.1.4203.1.9.1"
#define LDAP_CONTROL_SYNC LDAP_SYNC_OID ".1"
#define LDAP_CONTROL_SYNC_STATE LDAP_SYNC_OID ".2"
#define LDAP_CONTROL_SYNC_DONE LDAP_SYNC_OID ".3"
#define LDAP_SYNC_INFO LDAP_SYNC_OID ".4"
#define LDAP_SYNC_NONE 0x00
#define LDAP_SYNC_REFRESH_ONLY 0x01
#define LDAP_SYNC_RESERVED 0x02
#define LDAP_SYNC_REFRESH_AND_PERSIST 0x03
#define LDAP_SYNC_REFRESH_PRESENTS 0
#define LDAP_SYNC_REFRESH_DELETES 1
#define LDAP_TAG_SYNC_NEW_COOKIE ((ber_tag_t) 0x80U)
#define LDAP_TAG_SYNC_REFRESH_DELETE ((ber_tag_t) 0xa1U)
#define LDAP_TAG_SYNC_REFRESH_PRESENT ((ber_tag_t) 0xa2U)
#define LDAP_TAG_SYNC_ID_SET ((ber_tag_t) 0xa3U)
#define LDAP_TAG_SYNC_COOKIE ((ber_tag_t) 0x04U)
#define LDAP_TAG_REFRESHDELETES ((ber_tag_t) 0x01U)
#define LDAP_TAG_REFRESHDONE ((ber_tag_t) 0x01U)
#define LDAP_TAG_RELOAD_HINT ((ber_tag_t) 0x01U)
#define LDAP_SYNC_PRESENT 0
#define LDAP_SYNC_ADD 1
#define LDAP_SYNC_MODIFY 2
#define LDAP_SYNC_DELETE 3
#define LDAP_SYNC_NEW_COOKIE 4
/* Password policy Controls *//* work in progress */
/* ITS#3458: released; disabled by default */
#define LDAP_CONTROL_PASSWORDPOLICYREQUEST "1.3.6.1.4.1.42.2.27.8.5.1"
#define LDAP_CONTROL_PASSWORDPOLICYRESPONSE "1.3.6.1.4.1.42.2.27.8.5.1"
/* various works in progress */
#define LDAP_CONTROL_NOOP "1.3.6.1.4.1.4203.666.5.2"
#define LDAP_CONTROL_NO_SUBORDINATES "1.3.6.1.4.1.4203.666.5.11"
#define LDAP_CONTROL_RELAX "1.3.6.1.4.1.4203.666.5.12"
#define LDAP_CONTROL_MANAGEDIT LDAP_CONTROL_RELAX
#define LDAP_CONTROL_SLURP "1.3.6.1.4.1.4203.666.5.13"
#define LDAP_CONTROL_VALSORT "1.3.6.1.4.1.4203.666.5.14"
#define LDAP_CONTROL_DONTUSECOPY "1.3.6.1.4.1.4203.666.5.15"
#define LDAP_CONTROL_X_DEREF "1.3.6.1.4.1.4203.666.5.16"
#define LDAP_CONTROL_X_WHATFAILED "1.3.6.1.4.1.4203.666.5.17"
/* LDAP Chaining Behavior Control *//* work in progress */
/* ;
* see also LDAP_NO_REFERRALS_FOUND, LDAP_CANNOT_CHAIN */
#define LDAP_CONTROL_X_CHAINING_BEHAVIOR "1.3.6.1.4.1.4203.666.11.3"
#define LDAP_CHAINING_PREFERRED 0
#define LDAP_CHAINING_REQUIRED 1
#define LDAP_REFERRALS_PREFERRED 2
#define LDAP_REFERRALS_REQUIRED 3
/* MS Active Directory controls (for compatibility) */
#define LDAP_CONTROL_X_INCREMENTAL_VALUES "1.2.840.113556.1.4.802"
#define LDAP_CONTROL_X_DOMAIN_SCOPE "1.2.840.113556.1.4.1339"
#define LDAP_CONTROL_X_PERMISSIVE_MODIFY "1.2.840.113556.1.4.1413"
#define LDAP_CONTROL_X_SEARCH_OPTIONS "1.2.840.113556.1.4.1340"
#define LDAP_SEARCH_FLAG_DOMAIN_SCOPE 1 /* do not generate referrals */
#define LDAP_SEARCH_FLAG_PHANTOM_ROOT 2 /* search all subordinate NCs */
#define LDAP_CONTROL_X_TREE_DELETE "1.2.840.113556.1.4.805"
/* MS Active Directory controls - not implemented in slapd(8) */
#define LDAP_CONTROL_X_EXTENDED_DN "1.2.840.113556.1.4.529"
/* */
#define LDAP_CONTROL_X_SESSION_TRACKING "1.3.6.1.4.1.21008.108.63.1"
#define LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_SESSION_ID \
LDAP_CONTROL_X_SESSION_TRACKING ".1"
#define LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_MULTI_SESSION_ID \
LDAP_CONTROL_X_SESSION_TRACKING ".2"
#define LDAP_CONTROL_X_SESSION_TRACKING_USERNAME \
LDAP_CONTROL_X_SESSION_TRACKING ".3"
/* various expired works */
/* LDAP Duplicated Entry Control Extension *//* not implemented in slapd(8) */
#define LDAP_CONTROL_DUPENT_REQUEST "2.16.840.1.113719.1.27.101.1"
#define LDAP_CONTROL_DUPENT_RESPONSE "2.16.840.1.113719.1.27.101.2"
#define LDAP_CONTROL_DUPENT_ENTRY "2.16.840.1.113719.1.27.101.3"
#define LDAP_CONTROL_DUPENT LDAP_CONTROL_DUPENT_REQUEST
/* LDAP Persistent Search Control *//* not implemented in slapd(8) */
#define LDAP_CONTROL_PERSIST_REQUEST "2.16.840.1.113730.3.4.3"
#define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_NOTICE "2.16.840.1.113730.3.4.7"
#define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_ADD 0x1
#define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_DELETE 0x2
#define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_MODIFY 0x4
#define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_RENAME 0x8
/* LDAP VLV */
#define LDAP_CONTROL_VLVREQUEST "2.16.840.1.113730.3.4.9"
#define LDAP_CONTROL_VLVRESPONSE "2.16.840.1.113730.3.4.10"
/* LDAP Unsolicited Notifications */
#define LDAP_NOTICE_OF_DISCONNECTION "1.3.6.1.4.1.1466.20036" /* RFC 4511 */
#define LDAP_NOTICE_DISCONNECT LDAP_NOTICE_OF_DISCONNECTION
/* LDAP Extended Operations */
#define LDAP_EXOP_START_TLS "1.3.6.1.4.1.1466.20037" /* RFC 4511 */
#define LDAP_EXOP_MODIFY_PASSWD "1.3.6.1.4.1.4203.1.11.1" /* RFC 3062 */
#define LDAP_TAG_EXOP_MODIFY_PASSWD_ID ((ber_tag_t) 0x80U)
#define LDAP_TAG_EXOP_MODIFY_PASSWD_OLD ((ber_tag_t) 0x81U)
#define LDAP_TAG_EXOP_MODIFY_PASSWD_NEW ((ber_tag_t) 0x82U)
#define LDAP_TAG_EXOP_MODIFY_PASSWD_GEN ((ber_tag_t) 0x80U)
#define LDAP_EXOP_CANCEL "1.3.6.1.1.8" /* RFC 3909 */
#define LDAP_EXOP_X_CANCEL LDAP_EXOP_CANCEL
#define LDAP_EXOP_REFRESH "1.3.6.1.4.1.1466.101.119.1" /* RFC 2589 */
#define LDAP_TAG_EXOP_REFRESH_REQ_DN ((ber_tag_t) 0x80U)
#define LDAP_TAG_EXOP_REFRESH_REQ_TTL ((ber_tag_t) 0x81U)
#define LDAP_TAG_EXOP_REFRESH_RES_TTL ((ber_tag_t) 0x81U)
#define LDAP_EXOP_WHO_AM_I "1.3.6.1.4.1.4203.1.11.3" /* RFC 4532 */
#define LDAP_EXOP_X_WHO_AM_I LDAP_EXOP_WHO_AM_I
/* various works in progress */
#define LDAP_EXOP_TURN "1.3.6.1.1.19" /* RFC 4531 */
#define LDAP_EXOP_X_TURN LDAP_EXOP_TURN
/* LDAP Distributed Procedures */
/* a work in progress */
#define LDAP_X_DISTPROC_BASE "1.3.6.1.4.1.4203.666.11.6"
#define LDAP_EXOP_X_CHAINEDREQUEST LDAP_X_DISTPROC_BASE ".1"
#define LDAP_FEATURE_X_CANCHAINOPS LDAP_X_DISTPROC_BASE ".2"
#define LDAP_CONTROL_X_RETURNCONTREF LDAP_X_DISTPROC_BASE ".3"
#define LDAP_URLEXT_X_LOCALREFOID LDAP_X_DISTPROC_BASE ".4"
#define LDAP_URLEXT_X_REFTYPEOID LDAP_X_DISTPROC_BASE ".5"
#define LDAP_URLEXT_X_SEARCHEDSUBTREEOID \
LDAP_X_DISTPROC_BASE ".6"
#define LDAP_URLEXT_X_FAILEDNAMEOID LDAP_X_DISTPROC_BASE ".7"
#define LDAP_URLEXT_X_LOCALREF "x-localReference"
#define LDAP_URLEXT_X_REFTYPE "x-referenceType"
#define LDAP_URLEXT_X_SEARCHEDSUBTREE "x-searchedSubtree"
#define LDAP_URLEXT_X_FAILEDNAME "x-failedName"
#ifdef LDAP_DEVEL
#define LDAP_X_TXN "1.3.6.1.4.1.4203.666.11.7" /* tmp */
#define LDAP_EXOP_X_TXN_START LDAP_X_TXN ".1"
#define LDAP_CONTROL_X_TXN_SPEC LDAP_X_TXN ".2"
#define LDAP_EXOP_X_TXN_END LDAP_X_TXN ".3"
#define LDAP_EXOP_X_TXN_ABORTED_NOTICE LDAP_X_TXN ".4"
#endif
/* LDAP Features */
#define LDAP_FEATURE_ALL_OP_ATTRS "1.3.6.1.4.1.4203.1.5.1" /* RFC 3673 */
#define LDAP_FEATURE_OBJECTCLASS_ATTRS \
"1.3.6.1.4.1.4203.1.5.2" /* @objectClass - new number to be assigned */
#define LDAP_FEATURE_ABSOLUTE_FILTERS "1.3.6.1.4.1.4203.1.5.3" /* (&) (|) */
#define LDAP_FEATURE_LANGUAGE_TAG_OPTIONS "1.3.6.1.4.1.4203.1.5.4"
#define LDAP_FEATURE_LANGUAGE_RANGE_OPTIONS "1.3.6.1.4.1.4203.1.5.5"
#define LDAP_FEATURE_MODIFY_INCREMENT "1.3.6.1.1.14"
/* LDAP Experimental (works in progress) Features */
#define LDAP_FEATURE_SUBORDINATE_SCOPE \
"1.3.6.1.4.1.4203.666.8.1" /* "children" */
#define LDAP_FEATURE_CHILDREN_SCOPE LDAP_FEATURE_SUBORDINATE_SCOPE
/*
* specific LDAP instantiations of BER types we know about
*/
/* Overview of LBER tag construction
*
* Bits
* ______
* 8 7 | CLASS
* 0 0 = UNIVERSAL
* 0 1 = APPLICATION
* 1 0 = CONTEXT-SPECIFIC
* 1 1 = PRIVATE
* _____
* | 6 | DATA-TYPE
* 0 = PRIMITIVE
* 1 = CONSTRUCTED
* ___________
* | 5 ... 1 | TAG-NUMBER
*/
/* general stuff */
#define LDAP_TAG_MESSAGE ((ber_tag_t) 0x30U) /* constructed + 16 */
#define LDAP_TAG_MSGID ((ber_tag_t) 0x02U) /* integer */
#define LDAP_TAG_LDAPDN ((ber_tag_t) 0x04U) /* octet string */
#define LDAP_TAG_LDAPCRED ((ber_tag_t) 0x04U) /* octet string */
#define LDAP_TAG_CONTROLS ((ber_tag_t) 0xa0U) /* context specific + constructed + 0 */
#define LDAP_TAG_REFERRAL ((ber_tag_t) 0xa3U) /* context specific + constructed + 3 */
#define LDAP_TAG_NEWSUPERIOR ((ber_tag_t) 0x80U) /* context-specific + primitive + 0 */
#define LDAP_TAG_EXOP_REQ_OID ((ber_tag_t) 0x80U) /* context specific + primitive */
#define LDAP_TAG_EXOP_REQ_VALUE ((ber_tag_t) 0x81U) /* context specific + primitive */
#define LDAP_TAG_EXOP_RES_OID ((ber_tag_t) 0x8aU) /* context specific + primitive */
#define LDAP_TAG_EXOP_RES_VALUE ((ber_tag_t) 0x8bU) /* context specific + primitive */
#define LDAP_TAG_IM_RES_OID ((ber_tag_t) 0x80U) /* context specific + primitive */
#define LDAP_TAG_IM_RES_VALUE ((ber_tag_t) 0x81U) /* context specific + primitive */
#define LDAP_TAG_SASL_RES_CREDS ((ber_tag_t) 0x87U) /* context specific + primitive */
/* LDAP Request Messages */
#define LDAP_REQ_BIND ((ber_tag_t) 0x60U) /* application + constructed */
#define LDAP_REQ_UNBIND ((ber_tag_t) 0x42U) /* application + primitive */
#define LDAP_REQ_SEARCH ((ber_tag_t) 0x63U) /* application + constructed */
#define LDAP_REQ_MODIFY ((ber_tag_t) 0x66U) /* application + constructed */
#define LDAP_REQ_ADD ((ber_tag_t) 0x68U) /* application + constructed */
#define LDAP_REQ_DELETE ((ber_tag_t) 0x4aU) /* application + primitive */
#define LDAP_REQ_MODDN ((ber_tag_t) 0x6cU) /* application + constructed */
#define LDAP_REQ_MODRDN LDAP_REQ_MODDN
#define LDAP_REQ_RENAME LDAP_REQ_MODDN
#define LDAP_REQ_COMPARE ((ber_tag_t) 0x6eU) /* application + constructed */
#define LDAP_REQ_ABANDON ((ber_tag_t) 0x50U) /* application + primitive */
#define LDAP_REQ_EXTENDED ((ber_tag_t) 0x77U) /* application + constructed */
/* LDAP Response Messages */
#define LDAP_RES_BIND ((ber_tag_t) 0x61U) /* application + constructed */
#define LDAP_RES_SEARCH_ENTRY ((ber_tag_t) 0x64U) /* application + constructed */
#define LDAP_RES_SEARCH_REFERENCE ((ber_tag_t) 0x73U) /* V3: application + constructed */
#define LDAP_RES_SEARCH_RESULT ((ber_tag_t) 0x65U) /* application + constructed */
#define LDAP_RES_MODIFY ((ber_tag_t) 0x67U) /* application + constructed */
#define LDAP_RES_ADD ((ber_tag_t) 0x69U) /* application + constructed */
#define LDAP_RES_DELETE ((ber_tag_t) 0x6bU) /* application + constructed */
#define LDAP_RES_MODDN ((ber_tag_t) 0x6dU) /* application + constructed */
#define LDAP_RES_MODRDN LDAP_RES_MODDN /* application + constructed */
#define LDAP_RES_RENAME LDAP_RES_MODDN /* application + constructed */
#define LDAP_RES_COMPARE ((ber_tag_t) 0x6fU) /* application + constructed */
#define LDAP_RES_EXTENDED ((ber_tag_t) 0x78U) /* V3: application + constructed */
#define LDAP_RES_INTERMEDIATE ((ber_tag_t) 0x79U) /* V3+: application + constructed */
#define LDAP_RES_ANY (-1)
#define LDAP_RES_UNSOLICITED (0)
/* sasl methods */
#define LDAP_SASL_SIMPLE ((char*)0)
#define LDAP_SASL_NULL ("")
/* authentication methods available */
#define LDAP_AUTH_NONE ((ber_tag_t) 0x00U) /* no authentication */
#define LDAP_AUTH_SIMPLE ((ber_tag_t) 0x80U) /* context specific + primitive */
#define LDAP_AUTH_SASL ((ber_tag_t) 0xa3U) /* context specific + constructed */
#define LDAP_AUTH_KRBV4 ((ber_tag_t) 0xffU) /* means do both of the following */
#define LDAP_AUTH_KRBV41 ((ber_tag_t) 0x81U) /* context specific + primitive */
#define LDAP_AUTH_KRBV42 ((ber_tag_t) 0x82U) /* context specific + primitive */
/* used by the Windows API but not used on the wire */
#define LDAP_AUTH_NEGOTIATE ((ber_tag_t) 0x04FFU)
/* filter types */
#define LDAP_FILTER_AND ((ber_tag_t) 0xa0U) /* context specific + constructed */
#define LDAP_FILTER_OR ((ber_tag_t) 0xa1U) /* context specific + constructed */
#define LDAP_FILTER_NOT ((ber_tag_t) 0xa2U) /* context specific + constructed */
#define LDAP_FILTER_EQUALITY ((ber_tag_t) 0xa3U) /* context specific + constructed */
#define LDAP_FILTER_SUBSTRINGS ((ber_tag_t) 0xa4U) /* context specific + constructed */
#define LDAP_FILTER_GE ((ber_tag_t) 0xa5U) /* context specific + constructed */
#define LDAP_FILTER_LE ((ber_tag_t) 0xa6U) /* context specific + constructed */
#define LDAP_FILTER_PRESENT ((ber_tag_t) 0x87U) /* context specific + primitive */
#define LDAP_FILTER_APPROX ((ber_tag_t) 0xa8U) /* context specific + constructed */
#define LDAP_FILTER_EXT ((ber_tag_t) 0xa9U) /* context specific + constructed */
/* extended filter component types */
#define LDAP_FILTER_EXT_OID ((ber_tag_t) 0x81U) /* context specific */
#define LDAP_FILTER_EXT_TYPE ((ber_tag_t) 0x82U) /* context specific */
#define LDAP_FILTER_EXT_VALUE ((ber_tag_t) 0x83U) /* context specific */
#define LDAP_FILTER_EXT_DNATTRS ((ber_tag_t) 0x84U) /* context specific */
/* substring filter component types */
#define LDAP_SUBSTRING_INITIAL ((ber_tag_t) 0x80U) /* context specific */
#define LDAP_SUBSTRING_ANY ((ber_tag_t) 0x81U) /* context specific */
#define LDAP_SUBSTRING_FINAL ((ber_tag_t) 0x82U) /* context specific */
/* search scopes */
#define LDAP_SCOPE_BASE ((ber_int_t) 0x0000)
#define LDAP_SCOPE_BASEOBJECT LDAP_SCOPE_BASE
#define LDAP_SCOPE_ONELEVEL ((ber_int_t) 0x0001)
#define LDAP_SCOPE_ONE LDAP_SCOPE_ONELEVEL
#define LDAP_SCOPE_SUBTREE ((ber_int_t) 0x0002)
#define LDAP_SCOPE_SUB LDAP_SCOPE_SUBTREE
#define LDAP_SCOPE_SUBORDINATE ((ber_int_t) 0x0003) /* OpenLDAP extension */
#define LDAP_SCOPE_CHILDREN LDAP_SCOPE_SUBORDINATE
#define LDAP_SCOPE_DEFAULT ((ber_int_t) -1) /* OpenLDAP extension */
/* substring filter component types */
#define LDAP_SUBSTRING_INITIAL ((ber_tag_t) 0x80U) /* context specific */
#define LDAP_SUBSTRING_ANY ((ber_tag_t) 0x81U) /* context specific */
#define LDAP_SUBSTRING_FINAL ((ber_tag_t) 0x82U) /* context specific */
/*
* LDAP Result Codes
*/
#define LDAP_SUCCESS 0x00
#define LDAP_RANGE(n,x,y) (((x) <= (n)) && ((n) <= (y)))
#define LDAP_OPERATIONS_ERROR 0x01
#define LDAP_PROTOCOL_ERROR 0x02
#define LDAP_TIMELIMIT_EXCEEDED 0x03
#define LDAP_SIZELIMIT_EXCEEDED 0x04
#define LDAP_COMPARE_FALSE 0x05
#define LDAP_COMPARE_TRUE 0x06
#define LDAP_AUTH_METHOD_NOT_SUPPORTED 0x07
#define LDAP_STRONG_AUTH_NOT_SUPPORTED LDAP_AUTH_METHOD_NOT_SUPPORTED
#define LDAP_STRONG_AUTH_REQUIRED 0x08
#define LDAP_STRONGER_AUTH_REQUIRED LDAP_STRONG_AUTH_REQUIRED
#define LDAP_PARTIAL_RESULTS 0x09 /* LDAPv2+ (not LDAPv3) */
#define LDAP_REFERRAL 0x0a /* LDAPv3 */
#define LDAP_ADMINLIMIT_EXCEEDED 0x0b /* LDAPv3 */
#define LDAP_UNAVAILABLE_CRITICAL_EXTENSION 0x0c /* LDAPv3 */
#define LDAP_CONFIDENTIALITY_REQUIRED 0x0d /* LDAPv3 */
#define LDAP_SASL_BIND_IN_PROGRESS 0x0e /* LDAPv3 */
#define LDAP_ATTR_ERROR(n) LDAP_RANGE((n),0x10,0x15) /* 16-21 */
#define LDAP_NO_SUCH_ATTRIBUTE 0x10
#define LDAP_UNDEFINED_TYPE 0x11
#define LDAP_INAPPROPRIATE_MATCHING 0x12
#define LDAP_CONSTRAINT_VIOLATION 0x13
#define LDAP_TYPE_OR_VALUE_EXISTS 0x14
#define LDAP_INVALID_SYNTAX 0x15
#define LDAP_NAME_ERROR(n) LDAP_RANGE((n),0x20,0x24) /* 32-34,36 */
#define LDAP_NO_SUCH_OBJECT 0x20
#define LDAP_ALIAS_PROBLEM 0x21
#define LDAP_INVALID_DN_SYNTAX 0x22
#define LDAP_IS_LEAF 0x23 /* not LDAPv3 */
#define LDAP_ALIAS_DEREF_PROBLEM 0x24
#define LDAP_SECURITY_ERROR(n) LDAP_RANGE((n),0x2F,0x32) /* 47-50 */
#define LDAP_X_PROXY_AUTHZ_FAILURE 0x2F /* LDAPv3 proxy authorization */
#define LDAP_INAPPROPRIATE_AUTH 0x30
#define LDAP_INVALID_CREDENTIALS 0x31
#define LDAP_INSUFFICIENT_ACCESS 0x32
#define LDAP_SERVICE_ERROR(n) LDAP_RANGE((n),0x33,0x36) /* 51-54 */
#define LDAP_BUSY 0x33
#define LDAP_UNAVAILABLE 0x34
#define LDAP_UNWILLING_TO_PERFORM 0x35
#define LDAP_LOOP_DETECT 0x36
#define LDAP_UPDATE_ERROR(n) LDAP_RANGE((n),0x40,0x47) /* 64-69,71 */
#define LDAP_NAMING_VIOLATION 0x40
#define LDAP_OBJECT_CLASS_VIOLATION 0x41
#define LDAP_NOT_ALLOWED_ON_NONLEAF 0x42
#define LDAP_NOT_ALLOWED_ON_RDN 0x43
#define LDAP_ALREADY_EXISTS 0x44
#define LDAP_NO_OBJECT_CLASS_MODS 0x45
#define LDAP_RESULTS_TOO_LARGE 0x46 /* CLDAP */
#define LDAP_AFFECTS_MULTIPLE_DSAS 0x47
#define LDAP_VLV_ERROR 0x4C
#define LDAP_OTHER 0x50
/* LCUP operation codes (113-117) - not implemented */
#define LDAP_CUP_RESOURCES_EXHAUSTED 0x71
#define LDAP_CUP_SECURITY_VIOLATION 0x72
#define LDAP_CUP_INVALID_DATA 0x73
#define LDAP_CUP_UNSUPPORTED_SCHEME 0x74
#define LDAP_CUP_RELOAD_REQUIRED 0x75
/* Cancel operation codes (118-121) */
#define LDAP_CANCELLED 0x76
#define LDAP_NO_SUCH_OPERATION 0x77
#define LDAP_TOO_LATE 0x78
#define LDAP_CANNOT_CANCEL 0x79
/* Assertion control (122) */
#define LDAP_ASSERTION_FAILED 0x7A
/* Proxied Authorization Denied (123) */
#define LDAP_PROXIED_AUTHORIZATION_DENIED 0x7B
/* Experimental result codes */
#define LDAP_E_ERROR(n) LDAP_RANGE((n),0x1000,0x3FFF)
/* LDAP Sync (4096) */
#define LDAP_SYNC_REFRESH_REQUIRED 0x1000
/* Private Use result codes */
#define LDAP_X_ERROR(n) LDAP_RANGE((n),0x4000,0xFFFF)
#define LDAP_X_SYNC_REFRESH_REQUIRED 0x4100 /* defunct */
#define LDAP_X_ASSERTION_FAILED 0x410f /* defunct */
/* for the LDAP No-Op control */
#define LDAP_X_NO_OPERATION 0x410e
/* for the Chaining Behavior control (consecutive result codes requested;
* see ) */
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
#define LDAP_X_NO_REFERRALS_FOUND 0x4110
#define LDAP_X_CANNOT_CHAIN 0x4111
#endif
/* for Distributed Procedures (see ) */
#ifdef LDAP_X_DISTPROC_BASE
#define LDAP_X_INVALIDREFERENCE 0x4112
#endif
#ifdef LDAP_X_TXN
#define LDAP_X_TXN_SPECIFY_OKAY 0x4120
#define LDAP_X_TXN_ID_INVALID 0x4121
#endif
/* API Error Codes
*
* Based on draft-ietf-ldap-c-api-xx
* but with new negative code values
*/
#define LDAP_API_ERROR(n) ((n)<0)
#define LDAP_API_RESULT(n) ((n)<=0)
#define LDAP_SERVER_DOWN (-1)
#define LDAP_LOCAL_ERROR (-2)
#define LDAP_ENCODING_ERROR (-3)
#define LDAP_DECODING_ERROR (-4)
#define LDAP_TIMEOUT (-5)
#define LDAP_AUTH_UNKNOWN (-6)
#define LDAP_FILTER_ERROR (-7)
#define LDAP_USER_CANCELLED (-8)
#define LDAP_PARAM_ERROR (-9)
#define LDAP_NO_MEMORY (-10)
#define LDAP_CONNECT_ERROR (-11)
#define LDAP_NOT_SUPPORTED (-12)
#define LDAP_CONTROL_NOT_FOUND (-13)
#define LDAP_NO_RESULTS_RETURNED (-14)
#define LDAP_MORE_RESULTS_TO_RETURN (-15) /* Obsolete */
#define LDAP_CLIENT_LOOP (-16)
#define LDAP_REFERRAL_LIMIT_EXCEEDED (-17)
#define LDAP_X_CONNECTING (-18)
/*
* This structure represents both ldap messages and ldap responses.
* These are really the same, except in the case of search responses,
* where a response has multiple messages.
*/
typedef struct ldapmsg LDAPMessage;
/* for modifications */
typedef struct ldapmod {
int mod_op;
#define LDAP_MOD_OP (0x0007)
#define LDAP_MOD_ADD (0x0000)
#define LDAP_MOD_DELETE (0x0001)
#define LDAP_MOD_REPLACE (0x0002)
#define LDAP_MOD_INCREMENT (0x0003) /* OpenLDAP extension */
#define LDAP_MOD_BVALUES (0x0080)
/* IMPORTANT: do not use code 0x1000 (or above),
* it is used internally by the backends!
* (see ldap/servers/slapd/slap.h)
*/
char *mod_type;
union mod_vals_u {
char **modv_strvals;
struct berval **modv_bvals;
} mod_vals;
#define mod_values mod_vals.modv_strvals
#define mod_bvalues mod_vals.modv_bvals
} LDAPMod;
/*
* structure representing an ldap session which can
* encompass connections to multiple servers (in the
* face of referrals).
*/
typedef struct ldap LDAP;
#define LDAP_DEREF_NEVER 0x00
#define LDAP_DEREF_SEARCHING 0x01
#define LDAP_DEREF_FINDING 0x02
#define LDAP_DEREF_ALWAYS 0x03
#define LDAP_NO_LIMIT 0
/* how many messages to retrieve results for */
#define LDAP_MSG_ONE 0x00
#define LDAP_MSG_ALL 0x01
#define LDAP_MSG_RECEIVED 0x02
/*
* types for ldap URL handling
*/
typedef struct ldap_url_desc {
struct ldap_url_desc *lud_next;
char *lud_scheme;
char *lud_host;
int lud_port;
char *lud_dn;
char **lud_attrs;
int lud_scope;
char *lud_filter;
char **lud_exts;
int lud_crit_exts;
} LDAPURLDesc;
#define LDAP_URL_SUCCESS 0x00 /* Success */
#define LDAP_URL_ERR_MEM 0x01 /* can't allocate memory space */
#define LDAP_URL_ERR_PARAM 0x02 /* parameter is bad */
#define LDAP_URL_ERR_BADSCHEME 0x03 /* URL doesn't begin with "ldap[si]://" */
#define LDAP_URL_ERR_BADENCLOSURE 0x04 /* URL is missing trailing ">" */
#define LDAP_URL_ERR_BADURL 0x05 /* URL is bad */
#define LDAP_URL_ERR_BADHOST 0x06 /* host port is bad */
#define LDAP_URL_ERR_BADATTRS 0x07 /* bad (or missing) attributes */
#define LDAP_URL_ERR_BADSCOPE 0x08 /* scope string is invalid (or missing) */
#define LDAP_URL_ERR_BADFILTER 0x09 /* bad or missing filter */
#define LDAP_URL_ERR_BADEXTS 0x0a /* bad or missing extensions */
/*
* LDAP sync (RFC4533) API
*/
typedef struct ldap_sync_t ldap_sync_t;
typedef enum {
/* these are private - the client should never see them */
LDAP_SYNC_CAPI_NONE = -1,
LDAP_SYNC_CAPI_PHASE_FLAG = 0x10U,
LDAP_SYNC_CAPI_IDSET_FLAG = 0x20U,
LDAP_SYNC_CAPI_DONE_FLAG = 0x40U,
/* these are passed to ls_search_entry() */
LDAP_SYNC_CAPI_PRESENT = LDAP_SYNC_PRESENT,
LDAP_SYNC_CAPI_ADD = LDAP_SYNC_ADD,
LDAP_SYNC_CAPI_MODIFY = LDAP_SYNC_MODIFY,
LDAP_SYNC_CAPI_DELETE = LDAP_SYNC_DELETE,
/* these are passed to ls_intermediate() */
LDAP_SYNC_CAPI_PRESENTS = ( LDAP_SYNC_CAPI_PHASE_FLAG | LDAP_SYNC_CAPI_PRESENT ),
LDAP_SYNC_CAPI_DELETES = ( LDAP_SYNC_CAPI_PHASE_FLAG | LDAP_SYNC_CAPI_DELETE ),
LDAP_SYNC_CAPI_PRESENTS_IDSET = ( LDAP_SYNC_CAPI_PRESENTS | LDAP_SYNC_CAPI_IDSET_FLAG ),
LDAP_SYNC_CAPI_DELETES_IDSET = ( LDAP_SYNC_CAPI_DELETES | LDAP_SYNC_CAPI_IDSET_FLAG ),
LDAP_SYNC_CAPI_DONE = ( LDAP_SYNC_CAPI_DONE_FLAG | LDAP_SYNC_CAPI_PRESENTS )
} ldap_sync_refresh_t;
/*
* Called when an entry is returned by ldap_result().
* If phase is LDAP_SYNC_CAPI_ADD or LDAP_SYNC_CAPI_MODIFY,
* the entry has been either added or modified, and thus
* the complete view of the entry should be in the LDAPMessage.
* If phase is LDAP_SYNC_CAPI_PRESENT or LDAP_SYNC_CAPI_DELETE,
* only the DN should be in the LDAPMessage.
*/
typedef int (*ldap_sync_search_entry_f) LDAP_P((
ldap_sync_t *ls,
LDAPMessage *msg,
struct berval *entryUUID,
ldap_sync_refresh_t phase ));
/*
* Called when a reference is returned; the client should know
* what to do with it.
*/
typedef int (*ldap_sync_search_reference_f) LDAP_P((
ldap_sync_t *ls,
LDAPMessage *msg ));
/*
* Called when specific intermediate/final messages are returned.
* If phase is LDAP_SYNC_CAPI_PRESENTS or LDAP_SYNC_CAPI_DELETES,
* a "presents" or "deletes" phase begins.
* If phase is LDAP_SYNC_CAPI_DONE, a special "presents" phase
* with refreshDone set to "TRUE" has been returned, to indicate
* that the refresh phase of a refreshAndPersist is complete.
* In the above cases, syncUUIDs is NULL.
*
* If phase is LDAP_SYNC_CAPI_PRESENTS_IDSET or
* LDAP_SYNC_CAPI_DELETES_IDSET, syncUUIDs is an array of UUIDs
* that are either present or have been deleted.
*/
typedef int (*ldap_sync_intermediate_f) LDAP_P((
ldap_sync_t *ls,
LDAPMessage *msg,
BerVarray syncUUIDs,
ldap_sync_refresh_t phase ));
/*
* Called when a searchResultDone is returned. In refreshAndPersist,
* this can only occur if the search for any reason is being terminated
* by the server.
*/
typedef int (*ldap_sync_search_result_f) LDAP_P((
ldap_sync_t *ls,
LDAPMessage *msg,
int refreshDeletes ));
/*
* This structure contains all information about the persistent search;
* the caller is responsible for connecting, setting version, binding, tls...
*/
struct ldap_sync_t {
/* conf search params */
char *ls_base;
int ls_scope;
char *ls_filter;
char **ls_attrs;
int ls_timelimit;
int ls_sizelimit;
/* poll timeout */
int ls_timeout;
/* helpers - add as appropriate */
ldap_sync_search_entry_f ls_search_entry;
ldap_sync_search_reference_f ls_search_reference;
ldap_sync_intermediate_f ls_intermediate;
ldap_sync_search_result_f ls_search_result;
/* set by the caller as appropriate */
void *ls_private;
/* conn stuff */
LDAP *ls_ld;
/* --- the parameters below are private - do not modify --- */
/* FIXME: make the structure opaque, and provide an interface
* to modify the public values? */
/* result stuff */
int ls_msgid;
/* sync stuff */
/* needed by refreshOnly */
int ls_reloadHint;
/* opaque - need to pass between sessions, updated by the API */
struct berval ls_cookie;
/* state variable - do not modify */
ldap_sync_refresh_t ls_refreshPhase;
};
/*
* End of LDAP sync (RFC4533) API
*/
/*
* Connection callbacks...
*/
struct ldap_conncb;
struct sockaddr;
/* Called after a connection is established */
typedef int (ldap_conn_add_f) LDAP_P(( LDAP *ld, Sockbuf *sb, LDAPURLDesc *srv, struct sockaddr *addr,
struct ldap_conncb *ctx ));
/* Called before a connection is closed */
typedef void (ldap_conn_del_f) LDAP_P(( LDAP *ld, Sockbuf *sb, struct ldap_conncb *ctx ));
/* Callbacks are pushed on a stack. Last one pushed is first one executed. The
* delete callback is called with a NULL Sockbuf just before freeing the LDAP handle.
*/
typedef struct ldap_conncb {
ldap_conn_add_f *lc_add;
ldap_conn_del_f *lc_del;
void *lc_arg;
} ldap_conncb;
/*
* The API draft spec says we should declare (or cause to be declared)
* 'struct timeval'. We don't. See IETF LDAPext discussions.
*/
struct timeval;
/*
* in options.c:
*/
LDAP_F( int )
ldap_get_option LDAP_P((
LDAP *ld,
int option,
void *outvalue));
LDAP_F( int )
ldap_set_option LDAP_P((
LDAP *ld,
int option,
LDAP_CONST void *invalue));
/* V3 REBIND Function Callback Prototype */
typedef int (LDAP_REBIND_PROC) LDAP_P((
LDAP *ld, LDAP_CONST char *url,
ber_tag_t request, ber_int_t msgid,
void *params ));
LDAP_F( int )
ldap_set_rebind_proc LDAP_P((
LDAP *ld,
LDAP_REBIND_PROC *rebind_proc,
void *params ));
/* V3 referral selection Function Callback Prototype */
typedef int (LDAP_NEXTREF_PROC) LDAP_P((
LDAP *ld, char ***refsp, int *cntp,
void *params ));
LDAP_F( int )
ldap_set_nextref_proc LDAP_P((
LDAP *ld,
LDAP_NEXTREF_PROC *nextref_proc,
void *params ));
/* V3 URLLIST Function Callback Prototype */
typedef int (LDAP_URLLIST_PROC) LDAP_P((
LDAP *ld,
LDAPURLDesc **urllist,
LDAPURLDesc **url,
void *params ));
LDAP_F( int )
ldap_set_urllist_proc LDAP_P((
LDAP *ld,
LDAP_URLLIST_PROC *urllist_proc,
void *params ));
/*
* in controls.c:
*/
#if LDAP_DEPRECATED
LDAP_F( int )
ldap_create_control LDAP_P(( /* deprecated, use ldap_control_create */
LDAP_CONST char *requestOID,
BerElement *ber,
int iscritical,
LDAPControl **ctrlp ));
LDAP_F( LDAPControl * )
ldap_find_control LDAP_P(( /* deprecated, use ldap_control_find */
LDAP_CONST char *oid,
LDAPControl **ctrls ));
#endif
LDAP_F( int )
ldap_control_create LDAP_P((
LDAP_CONST char *requestOID,
int iscritical,
struct berval *value,
int dupval,
LDAPControl **ctrlp ));
LDAP_F( LDAPControl * )
ldap_control_find LDAP_P((
LDAP_CONST char *oid,
LDAPControl **ctrls,
LDAPControl ***nextctrlp ));
LDAP_F( void )
ldap_control_free LDAP_P((
LDAPControl *ctrl ));
LDAP_F( void )
ldap_controls_free LDAP_P((
LDAPControl **ctrls ));
LDAP_F( LDAPControl ** )
ldap_controls_dup LDAP_P((
LDAPControl *LDAP_CONST *controls ));
LDAP_F( LDAPControl * )
ldap_control_dup LDAP_P((
LDAP_CONST LDAPControl *c ));
/*
* in dnssrv.c:
*/
LDAP_F( int )
ldap_domain2dn LDAP_P((
LDAP_CONST char* domain,
char** dn ));
LDAP_F( int )
ldap_dn2domain LDAP_P((
LDAP_CONST char* dn,
char** domain ));
LDAP_F( int )
ldap_domain2hostlist LDAP_P((
LDAP_CONST char *domain,
char** hostlist ));
/*
* in extended.c:
*/
LDAP_F( int )
ldap_extended_operation LDAP_P((
LDAP *ld,
LDAP_CONST char *reqoid,
struct berval *reqdata,
LDAPControl **serverctrls,
LDAPControl **clientctrls,
int *msgidp ));
LDAP_F( int )
ldap_extended_operation_s LDAP_P((
LDAP *ld,
LDAP_CONST char *reqoid,
struct berval *reqdata,
LDAPControl **serverctrls,
LDAPControl **clientctrls,
char **retoidp,
struct berval **retdatap ));
LDAP_F( int )
ldap_parse_extended_result LDAP_P((
LDAP *ld,
LDAPMessage *res,
char **retoidp,
struct berval **retdatap,
int freeit ));
LDAP_F( int )
ldap_parse_intermediate LDAP_P((
LDAP *ld,
LDAPMessage *res,
char **retoidp,
struct berval **retdatap,
LDAPControl ***serverctrls,
int freeit ));
/*
* in abandon.c:
*/
LDAP_F( int )
ldap_abandon_ext LDAP_P((
LDAP *ld,
int msgid,
LDAPControl **serverctrls,
LDAPControl **clientctrls ));
#if LDAP_DEPRECATED
LDAP_F( int )
ldap_abandon LDAP_P(( /* deprecated, use ldap_abandon_ext */
LDAP *ld,
int msgid ));
#endif
/*
* in add.c:
*/
LDAP_F( int )
ldap_add_ext LDAP_P((
LDAP *ld,
LDAP_CONST char *dn,
LDAPMod **attrs,
LDAPControl **serverctrls,
LDAPControl **clientctrls,
int *msgidp ));
LDAP_F( int )
ldap_add_ext_s LDAP_P((
LDAP *ld,
LDAP_CONST char *dn,
LDAPMod **attrs,
LDAPControl **serverctrls,
LDAPControl **clientctrls ));
#if LDAP_DEPRECATED
LDAP_F( int )
ldap_add LDAP_P(( /* deprecated, use ldap_add_ext */
LDAP *ld,
LDAP_CONST char *dn,
LDAPMod **attrs ));
LDAP_F( int )
ldap_add_s LDAP_P(( /* deprecated, use ldap_add_ext_s */
LDAP *ld,
LDAP_CONST char *dn,
LDAPMod **attrs ));
#endif
/*
* in sasl.c:
*/
LDAP_F( int )
ldap_sasl_bind LDAP_P((
LDAP *ld,
LDAP_CONST char *dn,
LDAP_CONST char *mechanism,
struct berval *cred,
LDAPControl **serverctrls,
LDAPControl **clientctrls,
int *msgidp ));
/* Interaction flags (should be passed about in a control)
* Automatic (default): use defaults, prompt otherwise
* Interactive: prompt always
* Quiet: never prompt
*/
#define LDAP_SASL_AUTOMATIC 0U
#define LDAP_SASL_INTERACTIVE 1U
#define LDAP_SASL_QUIET 2U
/*
* V3 SASL Interaction Function Callback Prototype
* when using Cyrus SASL, interact is pointer to sasl_interact_t
* should likely passed in a control (and provided controls)
*/
typedef int (LDAP_SASL_INTERACT_PROC) LDAP_P((
LDAP *ld, unsigned flags, void* defaults, void *interact ));
LDAP_F( int )
ldap_sasl_interactive_bind LDAP_P((
LDAP *ld,
LDAP_CONST char *dn, /* usually NULL */
LDAP_CONST char *saslMechanism,
LDAPControl **serverControls,
LDAPControl **clientControls,
/* should be client controls */
unsigned flags,
LDAP_SASL_INTERACT_PROC *proc,
void *defaults,
/* as obtained from ldap_result() */
LDAPMessage *result,
/* returned during bind processing */
const char **rmech,
int *msgid ));
LDAP_F( int )
ldap_sasl_interactive_bind_s LDAP_P((
LDAP *ld,
LDAP_CONST char *dn, /* usually NULL */
LDAP_CONST char *saslMechanism,
LDAPControl **serverControls,
LDAPControl **clientControls,
/* should be client controls */
unsigned flags,
LDAP_SASL_INTERACT_PROC *proc,
void *defaults ));
LDAP_F( int )
ldap_sasl_bind_s LDAP_P((
LDAP *ld,
LDAP_CONST char *dn,
LDAP_CONST char *mechanism,
struct berval *cred,
LDAPControl **serverctrls,
LDAPControl **clientctrls,
struct berval **servercredp ));
LDAP_F( int )
ldap_parse_sasl_bind_result LDAP_P((
LDAP *ld,
LDAPMessage *res,
struct berval **servercredp,
int freeit ));
#if LDAP_DEPRECATED
/*
* in bind.c:
* (deprecated)
*/
LDAP_F( int )
ldap_bind LDAP_P(( /* deprecated, use ldap_sasl_bind */
LDAP *ld,
LDAP_CONST char *who,
LDAP_CONST char *passwd,
int authmethod ));
LDAP_F( int )
ldap_bind_s LDAP_P(( /* deprecated, use ldap_sasl_bind_s */
LDAP *ld,
LDAP_CONST char *who,
LDAP_CONST char *cred,
int authmethod ));
/*
* in sbind.c:
*/
LDAP_F( int )
ldap_simple_bind LDAP_P(( /* deprecated, use ldap_sasl_bind */
LDAP *ld,
LDAP_CONST char *who,
LDAP_CONST char *passwd ));
LDAP_F( int )
ldap_simple_bind_s LDAP_P(( /* deprecated, use ldap_sasl_bind_s */
LDAP *ld,
LDAP_CONST char *who,
LDAP_CONST char *passwd ));
#endif
/*
* in compare.c:
*/
LDAP_F( int )
ldap_compare_ext LDAP_P((
LDAP *ld,
LDAP_CONST char *dn,
LDAP_CONST char *attr,
struct berval *bvalue,
LDAPControl **serverctrls,
LDAPControl **clientctrls,
int *msgidp ));
LDAP_F( int )
ldap_compare_ext_s LDAP_P((
LDAP *ld,
LDAP_CONST char *dn,
LDAP_CONST char *attr,
struct berval *bvalue,
LDAPControl **serverctrls,
LDAPControl **clientctrls ));
#if LDAP_DEPRECATED
LDAP_F( int )
ldap_compare LDAP_P(( /* deprecated, use ldap_compare_ext */
LDAP *ld,
LDAP_CONST char *dn,
LDAP_CONST char *attr,
LDAP_CONST char *value ));
LDAP_F( int )
ldap_compare_s LDAP_P(( /* deprecated, use ldap_compare_ext_s */
LDAP *ld,
LDAP_CONST char *dn,
LDAP_CONST char *attr,
LDAP_CONST char *value ));
#endif
/*
* in delete.c:
*/
LDAP_F( int )
ldap_delete_ext LDAP_P((
LDAP *ld,
LDAP_CONST char *dn,
LDAPControl **serverctrls,
LDAPControl **clientctrls,
int *msgidp ));
LDAP_F( int )
ldap_delete_ext_s LDAP_P((
LDAP *ld,
LDAP_CONST char *dn,
LDAPControl **serverctrls,
LDAPControl **clientctrls ));
#if LDAP_DEPRECATED
LDAP_F( int )
ldap_delete LDAP_P(( /* deprecated, use ldap_delete_ext */
LDAP *ld,
LDAP_CONST char *dn ));
LDAP_F( int )
ldap_delete_s LDAP_P(( /* deprecated, use ldap_delete_ext_s */
LDAP *ld,
LDAP_CONST char *dn ));
#endif
/*
* in error.c:
*/
LDAP_F( int )
ldap_parse_result LDAP_P((
LDAP *ld,
LDAPMessage *res,
int *errcodep,
char **matcheddnp,
char **errmsgp,
char ***referralsp,
LDAPControl ***serverctrls,
int freeit ));
LDAP_F( char * )
ldap_err2string LDAP_P((
int err ));
#if LDAP_DEPRECATED
LDAP_F( int )
ldap_result2error LDAP_P(( /* deprecated, use ldap_parse_result */
LDAP *ld,
LDAPMessage *r,
int freeit ));
LDAP_F( void )
ldap_perror LDAP_P(( /* deprecated, use ldap_err2string */
LDAP *ld,
LDAP_CONST char *s ));
#endif
/*
* gssapi.c:
*/
LDAP_F( int )
ldap_gssapi_bind LDAP_P((
LDAP *ld,
LDAP_CONST char *dn,
LDAP_CONST char *creds ));
LDAP_F( int )
ldap_gssapi_bind_s LDAP_P((
LDAP *ld,
LDAP_CONST char *dn,
LDAP_CONST char *creds ));
/*
* in modify.c:
*/
LDAP_F( int )
ldap_modify_ext LDAP_P((
LDAP *ld,
LDAP_CONST char *dn,
LDAPMod **mods,
LDAPControl **serverctrls,
LDAPControl **clientctrls,
int *msgidp ));
LDAP_F( int )
ldap_modify_ext_s LDAP_P((
LDAP *ld,
LDAP_CONST char *dn,
LDAPMod **mods,
LDAPControl **serverctrls,
LDAPControl **clientctrls ));
#if LDAP_DEPRECATED
LDAP_F( int )
ldap_modify LDAP_P(( /* deprecated, use ldap_modify_ext */
LDAP *ld,
LDAP_CONST char *dn,
LDAPMod **mods ));
LDAP_F( int )
ldap_modify_s LDAP_P(( /* deprecated, use ldap_modify_ext_s */
LDAP *ld,
LDAP_CONST char *dn,
LDAPMod **mods ));
#endif
/*
* in modrdn.c:
*/
LDAP_F( int )
ldap_rename LDAP_P((
LDAP *ld,
LDAP_CONST char *dn,
LDAP_CONST char *newrdn,
LDAP_CONST char *newSuperior,
int deleteoldrdn,
LDAPControl **sctrls,
LDAPControl **cctrls,
int *msgidp ));
LDAP_F( int )
ldap_rename_s LDAP_P((
LDAP *ld,
LDAP_CONST char *dn,
LDAP_CONST char *newrdn,
LDAP_CONST char *newSuperior,
int deleteoldrdn,
LDAPControl **sctrls,
LDAPControl **cctrls ));
#if LDAP_DEPRECATED
LDAP_F( int )
ldap_rename2 LDAP_P(( /* deprecated, use ldap_rename */
LDAP *ld,
LDAP_CONST char *dn,
LDAP_CONST char *newrdn,
LDAP_CONST char *newSuperior,
int deleteoldrdn ));
LDAP_F( int )
ldap_rename2_s LDAP_P(( /* deprecated, use ldap_rename_s */
LDAP *ld,
LDAP_CONST char *dn,
LDAP_CONST char *newrdn,
LDAP_CONST char *newSuperior,
int deleteoldrdn ));
LDAP_F( int )
ldap_modrdn LDAP_P(( /* deprecated, use ldap_rename */
LDAP *ld,
LDAP_CONST char *dn,
LDAP_CONST char *newrdn ));
LDAP_F( int )
ldap_modrdn_s LDAP_P(( /* deprecated, use ldap_rename_s */
LDAP *ld,
LDAP_CONST char *dn,
LDAP_CONST char *newrdn ));
LDAP_F( int )
ldap_modrdn2 LDAP_P(( /* deprecated, use ldap_rename */
LDAP *ld,
LDAP_CONST char *dn,
LDAP_CONST char *newrdn,
int deleteoldrdn ));
LDAP_F( int )
ldap_modrdn2_s LDAP_P(( /* deprecated, use ldap_rename_s */
LDAP *ld,
LDAP_CONST char *dn,
LDAP_CONST char *newrdn,
int deleteoldrdn));
#endif
/*
* in open.c:
*/
#if LDAP_DEPRECATED
LDAP_F( LDAP * )
ldap_init LDAP_P(( /* deprecated, use ldap_create or ldap_initialize */
LDAP_CONST char *host,
int port ));
LDAP_F( LDAP * )
ldap_open LDAP_P(( /* deprecated, use ldap_create or ldap_initialize */
LDAP_CONST char *host,
int port ));
#endif
LDAP_F( int )
ldap_create LDAP_P((
LDAP **ldp ));
LDAP_F( int )
ldap_initialize LDAP_P((
LDAP **ldp,
LDAP_CONST char *url ));
LDAP_F( LDAP * )
ldap_dup LDAP_P((
LDAP *old ));
/*
* in tls.c
*/
LDAP_F( int )
ldap_tls_inplace LDAP_P((
LDAP *ld ));
LDAP_F( int )
ldap_start_tls LDAP_P((
LDAP *ld,
LDAPControl **serverctrls,
LDAPControl **clientctrls,
int *msgidp ));
LDAP_F( int )
ldap_install_tls LDAP_P((
LDAP *ld ));
LDAP_F( int )
ldap_start_tls_s LDAP_P((
LDAP *ld,
LDAPControl **serverctrls,
LDAPControl **clientctrls ));
/*
* in messages.c:
*/
LDAP_F( LDAPMessage * )
ldap_first_message LDAP_P((
LDAP *ld,
LDAPMessage *chain ));
LDAP_F( LDAPMessage * )
ldap_next_message LDAP_P((
LDAP *ld,
LDAPMessage *msg ));
LDAP_F( int )
ldap_count_messages LDAP_P((
LDAP *ld,
LDAPMessage *chain ));
/*
* in references.c:
*/
LDAP_F( LDAPMessage * )
ldap_first_reference LDAP_P((
LDAP *ld,
LDAPMessage *chain ));
LDAP_F( LDAPMessage * )
ldap_next_reference LDAP_P((
LDAP *ld,
LDAPMessage *ref ));
LDAP_F( int )
ldap_count_references LDAP_P((
LDAP *ld,
LDAPMessage *chain ));
LDAP_F( int )
ldap_parse_reference LDAP_P((
LDAP *ld,
LDAPMessage *ref,
char ***referralsp,
LDAPControl ***serverctrls,
int freeit));
/*
* in getentry.c:
*/
LDAP_F( LDAPMessage * )
ldap_first_entry LDAP_P((
LDAP *ld,
LDAPMessage *chain ));
LDAP_F( LDAPMessage * )
ldap_next_entry LDAP_P((
LDAP *ld,
LDAPMessage *entry ));
LDAP_F( int )
ldap_count_entries LDAP_P((
LDAP *ld,
LDAPMessage *chain ));
LDAP_F( int )
ldap_get_entry_controls LDAP_P((
LDAP *ld,
LDAPMessage *entry,
LDAPControl ***serverctrls));
/*
* in addentry.c
*/
LDAP_F( LDAPMessage * )
ldap_delete_result_entry LDAP_P((
LDAPMessage **list,
LDAPMessage *e ));
LDAP_F( void )
ldap_add_result_entry LDAP_P((
LDAPMessage **list,
LDAPMessage *e ));
/*
* in getdn.c
*/
LDAP_F( char * )
ldap_get_dn LDAP_P((
LDAP *ld,
LDAPMessage *entry ));
typedef struct ldap_ava {
struct berval la_attr;
struct berval la_value;
unsigned la_flags;
#define LDAP_AVA_NULL 0x0000U
#define LDAP_AVA_STRING 0x0001U
#define LDAP_AVA_BINARY 0x0002U
#define LDAP_AVA_NONPRINTABLE 0x0004U
#define LDAP_AVA_FREE_ATTR 0x0010U
#define LDAP_AVA_FREE_VALUE 0x0020U
void *la_private;
} LDAPAVA;
typedef LDAPAVA** LDAPRDN;
typedef LDAPRDN* LDAPDN;
/* DN formats */
#define LDAP_DN_FORMAT_LDAP 0x0000U
#define LDAP_DN_FORMAT_LDAPV3 0x0010U
#define LDAP_DN_FORMAT_LDAPV2 0x0020U
#define LDAP_DN_FORMAT_DCE 0x0030U
#define LDAP_DN_FORMAT_UFN 0x0040U /* dn2str only */
#define LDAP_DN_FORMAT_AD_CANONICAL 0x0050U /* dn2str only */
#define LDAP_DN_FORMAT_LBER 0x00F0U /* for testing only */
#define LDAP_DN_FORMAT_MASK 0x00F0U
/* DN flags */
#define LDAP_DN_PRETTY 0x0100U
#define LDAP_DN_SKIP 0x0200U
#define LDAP_DN_P_NOLEADTRAILSPACES 0x1000U
#define LDAP_DN_P_NOSPACEAFTERRDN 0x2000U
#define LDAP_DN_PEDANTIC 0xF000U
LDAP_F( void ) ldap_rdnfree LDAP_P(( LDAPRDN rdn ));
LDAP_F( void ) ldap_dnfree LDAP_P(( LDAPDN dn ));
LDAP_F( int )
ldap_bv2dn LDAP_P((
struct berval *bv,
LDAPDN *dn,
unsigned flags ));
LDAP_F( int )
ldap_str2dn LDAP_P((
LDAP_CONST char *str,
LDAPDN *dn,
unsigned flags ));
LDAP_F( int )
ldap_dn2bv LDAP_P((
LDAPDN dn,
struct berval *bv,
unsigned flags ));
LDAP_F( int )
ldap_dn2str LDAP_P((
LDAPDN dn,
char **str,
unsigned flags ));
LDAP_F( int )
ldap_bv2rdn LDAP_P((
struct berval *bv,
LDAPRDN *rdn,
char **next,
unsigned flags ));
LDAP_F( int )
ldap_str2rdn LDAP_P((
LDAP_CONST char *str,
LDAPRDN *rdn,
char **next,
unsigned flags ));
LDAP_F( int )
ldap_rdn2bv LDAP_P((
LDAPRDN rdn,
struct berval *bv,
unsigned flags ));
LDAP_F( int )
ldap_rdn2str LDAP_P((
LDAPRDN rdn,
char **str,
unsigned flags ));
LDAP_F( int )
ldap_dn_normalize LDAP_P((
LDAP_CONST char *in, unsigned iflags,
char **out, unsigned oflags ));
LDAP_F( char * )
ldap_dn2ufn LDAP_P(( /* deprecated, use ldap_str2dn/dn2str */
LDAP_CONST char *dn ));
LDAP_F( char ** )
ldap_explode_dn LDAP_P(( /* deprecated, ldap_str2dn */
LDAP_CONST char *dn,
int notypes ));
LDAP_F( char ** )
ldap_explode_rdn LDAP_P(( /* deprecated, ldap_str2rdn */
LDAP_CONST char *rdn,
int notypes ));
typedef int LDAPDN_rewrite_func
LDAP_P(( LDAPDN dn, unsigned flags, void *ctx ));
LDAP_F( int )
ldap_X509dn2bv LDAP_P(( void *x509_name, struct berval *dn,
LDAPDN_rewrite_func *func, unsigned flags ));
LDAP_F( char * )
ldap_dn2dcedn LDAP_P(( /* deprecated, ldap_str2dn/dn2str */
LDAP_CONST char *dn ));
LDAP_F( char * )
ldap_dcedn2dn LDAP_P(( /* deprecated, ldap_str2dn/dn2str */
LDAP_CONST char *dce ));
LDAP_F( char * )
ldap_dn2ad_canonical LDAP_P(( /* deprecated, ldap_str2dn/dn2str */
LDAP_CONST char *dn ));
LDAP_F( int )
ldap_get_dn_ber LDAP_P((
LDAP *ld, LDAPMessage *e, BerElement **berout, struct berval *dn ));
LDAP_F( int )
ldap_get_attribute_ber LDAP_P((
LDAP *ld, LDAPMessage *e, BerElement *ber, struct berval *attr,
struct berval **vals ));
/*
* in getattr.c
*/
LDAP_F( char * )
ldap_first_attribute LDAP_P((
LDAP *ld,
LDAPMessage *entry,
BerElement **ber ));
LDAP_F( char * )
ldap_next_attribute LDAP_P((
LDAP *ld,
LDAPMessage *entry,
BerElement *ber ));
/*
* in getvalues.c
*/
LDAP_F( struct berval ** )
ldap_get_values_len LDAP_P((
LDAP *ld,
LDAPMessage *entry,
LDAP_CONST char *target ));
LDAP_F( int )
ldap_count_values_len LDAP_P((
struct berval **vals ));
LDAP_F( void )
ldap_value_free_len LDAP_P((
struct berval **vals ));
#if LDAP_DEPRECATED
LDAP_F( char ** )
ldap_get_values LDAP_P(( /* deprecated, use ldap_get_values_len */
LDAP *ld,
LDAPMessage *entry,
LDAP_CONST char *target ));
LDAP_F( int )
ldap_count_values LDAP_P(( /* deprecated, use ldap_count_values_len */
char **vals ));
LDAP_F( void )
ldap_value_free LDAP_P(( /* deprecated, use ldap_value_free_len */
char **vals ));
#endif
/*
* in result.c:
*/
LDAP_F( int )
ldap_result LDAP_P((
LDAP *ld,
int msgid,
int all,
struct timeval *timeout,
LDAPMessage **result ));
LDAP_F( int )
ldap_msgtype LDAP_P((
LDAPMessage *lm ));
LDAP_F( int )
ldap_msgid LDAP_P((
LDAPMessage *lm ));
LDAP_F( int )
ldap_msgfree LDAP_P((
LDAPMessage *lm ));
LDAP_F( int )
ldap_msgdelete LDAP_P((
LDAP *ld,
int msgid ));
/*
* in search.c:
*/
LDAP_F( int )
ldap_bv2escaped_filter_value LDAP_P((
struct berval *in,
struct berval *out ));
LDAP_F( int )
ldap_search_ext LDAP_P((
LDAP *ld,
LDAP_CONST char *base,
int scope,
LDAP_CONST char *filter,
char **attrs,
int attrsonly,
LDAPControl **serverctrls,
LDAPControl **clientctrls,
struct timeval *timeout,
int sizelimit,
int *msgidp ));
LDAP_F( int )
ldap_search_ext_s LDAP_P((
LDAP *ld,
LDAP_CONST char *base,
int scope,
LDAP_CONST char *filter,
char **attrs,
int attrsonly,
LDAPControl **serverctrls,
LDAPControl **clientctrls,
struct timeval *timeout,
int sizelimit,
LDAPMessage **res ));
#if LDAP_DEPRECATED
LDAP_F( int )
ldap_search LDAP_P(( /* deprecated, use ldap_search_ext */
LDAP *ld,
LDAP_CONST char *base,
int scope,
LDAP_CONST char *filter,
char **attrs,
int attrsonly ));
LDAP_F( int )
ldap_search_s LDAP_P(( /* deprecated, use ldap_search_ext_s */
LDAP *ld,
LDAP_CONST char *base,
int scope,
LDAP_CONST char *filter,
char **attrs,
int attrsonly,
LDAPMessage **res ));
LDAP_F( int )
ldap_search_st LDAP_P(( /* deprecated, use ldap_search_ext_s */
LDAP *ld,
LDAP_CONST char *base,
int scope,
LDAP_CONST char *filter,
char **attrs,
int attrsonly,
struct timeval *timeout,
LDAPMessage **res ));
#endif
/*
* in unbind.c
*/
LDAP_F( int )
ldap_unbind_ext LDAP_P((
LDAP *ld,
LDAPControl **serverctrls,
LDAPControl **clientctrls));
LDAP_F( int )
ldap_unbind_ext_s LDAP_P((
LDAP *ld,
LDAPControl **serverctrls,
LDAPControl **clientctrls));
LDAP_F( int )
ldap_destroy LDAP_P((
LDAP *ld));
#if LDAP_DEPRECATED
LDAP_F( int )
ldap_unbind LDAP_P(( /* deprecated, use ldap_unbind_ext */
LDAP *ld ));
LDAP_F( int )
ldap_unbind_s LDAP_P(( /* deprecated, use ldap_unbind_ext_s */
LDAP *ld ));
#endif
/*
* in filter.c
*/
LDAP_F( int )
ldap_put_vrFilter LDAP_P((
BerElement *ber,
const char *vrf ));
/*
* in free.c
*/
LDAP_F( void * )
ldap_memalloc LDAP_P((
ber_len_t s ));
LDAP_F( void * )
ldap_memrealloc LDAP_P((
void* p,
ber_len_t s ));
LDAP_F( void * )
ldap_memcalloc LDAP_P((
ber_len_t n,
ber_len_t s ));
LDAP_F( void )
ldap_memfree LDAP_P((
void* p ));
LDAP_F( void )
ldap_memvfree LDAP_P((
void** v ));
LDAP_F( char * )
ldap_strdup LDAP_P((
LDAP_CONST char * ));
LDAP_F( void )
ldap_mods_free LDAP_P((
LDAPMod **mods,
int freemods ));
#if LDAP_DEPRECATED
/*
* in sort.c (deprecated, use custom code instead)
*/
typedef int (LDAP_SORT_AD_CMP_PROC) LDAP_P(( /* deprecated */
LDAP_CONST char *left,
LDAP_CONST char *right ));
typedef int (LDAP_SORT_AV_CMP_PROC) LDAP_P(( /* deprecated */
LDAP_CONST void *left,
LDAP_CONST void *right ));
LDAP_F( int ) /* deprecated */
ldap_sort_entries LDAP_P(( LDAP *ld,
LDAPMessage **chain,
LDAP_CONST char *attr,
LDAP_SORT_AD_CMP_PROC *cmp ));
LDAP_F( int ) /* deprecated */
ldap_sort_values LDAP_P((
LDAP *ld,
char **vals,
LDAP_SORT_AV_CMP_PROC *cmp ));
LDAP_F( int ) /* deprecated */
ldap_sort_strcasecmp LDAP_P((
LDAP_CONST void *a,
LDAP_CONST void *b ));
#endif
/*
* in url.c
*/
LDAP_F( int )
ldap_is_ldap_url LDAP_P((
LDAP_CONST char *url ));
LDAP_F( int )
ldap_is_ldaps_url LDAP_P((
LDAP_CONST char *url ));
LDAP_F( int )
ldap_is_ldapi_url LDAP_P((
LDAP_CONST char *url ));
LDAP_F( int )
ldap_url_parse LDAP_P((
LDAP_CONST char *url,
LDAPURLDesc **ludpp ));
LDAP_F( char * )
ldap_url_desc2str LDAP_P((
LDAPURLDesc *ludp ));
LDAP_F( void )
ldap_free_urldesc LDAP_P((
LDAPURLDesc *ludp ));
/*
* LDAP Cancel Extended Operation
* in cancel.c
*/
#define LDAP_API_FEATURE_CANCEL 1000
LDAP_F( int )
ldap_cancel LDAP_P(( LDAP *ld,
int cancelid,
LDAPControl **sctrls,
LDAPControl **cctrls,
int *msgidp ));
LDAP_F( int )
ldap_cancel_s LDAP_P(( LDAP *ld,
int cancelid,
LDAPControl **sctrl,
LDAPControl **cctrl ));
/*
* LDAP Turn Extended Operation
* in turn.c
*/
#define LDAP_API_FEATURE_TURN 1000
LDAP_F( int )
ldap_turn LDAP_P(( LDAP *ld,
int mutual,
LDAP_CONST char* identifier,
LDAPControl **sctrls,
LDAPControl **cctrls,
int *msgidp ));
LDAP_F( int )
ldap_turn_s LDAP_P(( LDAP *ld,
int mutual,
LDAP_CONST char* identifier,
LDAPControl **sctrl,
LDAPControl **cctrl ));
/*
* LDAP Paged Results
* in pagectrl.c
*/
#define LDAP_API_FEATURE_PAGED_RESULTS 2000
LDAP_F( int )
ldap_create_page_control_value LDAP_P((
LDAP *ld,
ber_int_t pagesize,
struct berval *cookie,
struct berval *value ));
LDAP_F( int )
ldap_create_page_control LDAP_P((
LDAP *ld,
ber_int_t pagesize,
struct berval *cookie,
int iscritical,
LDAPControl **ctrlp ));
#if LDAP_DEPRECATED
LDAP_F( int )
ldap_parse_page_control LDAP_P((
/* deprecated, use ldap_parse_pageresponse_control */
LDAP *ld,
LDAPControl **ctrls,
ber_int_t *count,
struct berval **cookie ));
#endif
LDAP_F( int )
ldap_parse_pageresponse_control LDAP_P((
LDAP *ld,
LDAPControl *ctrl,
ber_int_t *count,
struct berval *cookie ));
/*
* LDAP Server Side Sort
* in sortctrl.c
*/
#define LDAP_API_FEATURE_SERVER_SIDE_SORT 2000
/* structure for a sort-key */
typedef struct ldapsortkey {
char *attributeType;
char *orderingRule;
int reverseOrder;
} LDAPSortKey;
LDAP_F( int )
ldap_create_sort_keylist LDAP_P((
LDAPSortKey ***sortKeyList,
char *keyString ));
LDAP_F( void )
ldap_free_sort_keylist LDAP_P((
LDAPSortKey **sortkeylist ));
LDAP_F( int )
ldap_create_sort_control_value LDAP_P((
LDAP *ld,
LDAPSortKey **keyList,
struct berval *value ));
LDAP_F( int )
ldap_create_sort_control LDAP_P((
LDAP *ld,
LDAPSortKey **keyList,
int iscritical,
LDAPControl **ctrlp ));
LDAP_F( int )
ldap_parse_sortresponse_control LDAP_P((
LDAP *ld,
LDAPControl *ctrl,
ber_int_t *result,
char **attribute ));
/*
* LDAP Virtual List View
* in vlvctrl.c
*/
#define LDAP_API_FEATURE_VIRTUAL_LIST_VIEW 2000
/* structure for virtual list */
typedef struct ldapvlvinfo {
ber_int_t ldvlv_version;
ber_int_t ldvlv_before_count;
ber_int_t ldvlv_after_count;
ber_int_t ldvlv_offset;
ber_int_t ldvlv_count;
struct berval * ldvlv_attrvalue;
struct berval * ldvlv_context;
void * ldvlv_extradata;
} LDAPVLVInfo;
LDAP_F( int )
ldap_create_vlv_control_value LDAP_P((
LDAP *ld,
LDAPVLVInfo *ldvlistp,
struct berval *value));
LDAP_F( int )
ldap_create_vlv_control LDAP_P((
LDAP *ld,
LDAPVLVInfo *ldvlistp,
LDAPControl **ctrlp ));
LDAP_F( int )
ldap_parse_vlvresponse_control LDAP_P((
LDAP *ld,
LDAPControl *ctrls,
ber_int_t *target_posp,
ber_int_t *list_countp,
struct berval **contextp,
int *errcodep ));
/*
* LDAP Who Am I?
* in whoami.c
*/
#define LDAP_API_FEATURE_WHOAMI 1000
LDAP_F( int )
ldap_parse_whoami LDAP_P((
LDAP *ld,
LDAPMessage *res,
struct berval **authzid ));
LDAP_F( int )
ldap_whoami LDAP_P(( LDAP *ld,
LDAPControl **sctrls,
LDAPControl **cctrls,
int *msgidp ));
LDAP_F( int )
ldap_whoami_s LDAP_P((
LDAP *ld,
struct berval **authzid,
LDAPControl **sctrls,
LDAPControl **cctrls ));
/*
* LDAP Password Modify
* in passwd.c
*/
#define LDAP_API_FEATURE_PASSWD_MODIFY 1000
LDAP_F( int )
ldap_parse_passwd LDAP_P((
LDAP *ld,
LDAPMessage *res,
struct berval *newpasswd ));
LDAP_F( int )
ldap_passwd LDAP_P(( LDAP *ld,
struct berval *user,
struct berval *oldpw,
struct berval *newpw,
LDAPControl **sctrls,
LDAPControl **cctrls,
int *msgidp ));
LDAP_F( int )
ldap_passwd_s LDAP_P((
LDAP *ld,
struct berval *user,
struct berval *oldpw,
struct berval *newpw,
struct berval *newpasswd,
LDAPControl **sctrls,
LDAPControl **cctrls ));
#ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
/*
* LDAP Password Policy controls
* in ppolicy.c
*/
#define LDAP_API_FEATURE_PASSWORD_POLICY 1000
typedef enum passpolicyerror_enum {
PP_passwordExpired = 0,
PP_accountLocked = 1,
PP_changeAfterReset = 2,
PP_passwordModNotAllowed = 3,
PP_mustSupplyOldPassword = 4,
PP_insufficientPasswordQuality = 5,
PP_passwordTooShort = 6,
PP_passwordTooYoung = 7,
PP_passwordInHistory = 8,
PP_noError = 65535
} LDAPPasswordPolicyError;
LDAP_F( int )
ldap_create_passwordpolicy_control LDAP_P((
LDAP *ld,
LDAPControl **ctrlp ));
LDAP_F( int )
ldap_parse_passwordpolicy_control LDAP_P((
LDAP *ld,
LDAPControl *ctrl,
ber_int_t *expirep,
ber_int_t *gracep,
LDAPPasswordPolicyError *errorp ));
LDAP_F( const char * )
ldap_passwordpolicy_err2txt LDAP_P(( LDAPPasswordPolicyError ));
#endif /* LDAP_CONTROL_PASSWORDPOLICYREQUEST */
/*
* LDAP Dynamic Directory Services Refresh -- RFC 2589
* in dds.c
*/
#define LDAP_API_FEATURE_REFRESH 1000
LDAP_F( int )
ldap_parse_refresh LDAP_P((
LDAP *ld,
LDAPMessage *res,
ber_int_t *newttl ));
LDAP_F( int )
ldap_refresh LDAP_P(( LDAP *ld,
struct berval *dn,
ber_int_t ttl,
LDAPControl **sctrls,
LDAPControl **cctrls,
int *msgidp ));
LDAP_F( int )
ldap_refresh_s LDAP_P((
LDAP *ld,
struct berval *dn,
ber_int_t ttl,
ber_int_t *newttl,
LDAPControl **sctrls,
LDAPControl **cctrls ));
/*
* LDAP Transactions
*/
#ifdef LDAP_X_TXN
LDAP_F( int )
ldap_txn_start LDAP_P(( LDAP *ld,
LDAPControl **sctrls,
LDAPControl **cctrls,
int *msgidp ));
LDAP_F( int )
ldap_txn_start_s LDAP_P(( LDAP *ld,
LDAPControl **sctrl,
LDAPControl **cctrl,
struct berval **rettxnid ));
LDAP_F( int )
ldap_txn_end LDAP_P(( LDAP *ld,
int commit,
struct berval *txnid,
LDAPControl **sctrls,
LDAPControl **cctrls,
int *msgidp ));
LDAP_F( int )
ldap_txn_end_s LDAP_P(( LDAP *ld,
int commit,
struct berval *txnid,
LDAPControl **sctrl,
LDAPControl **cctrl,
int *retidp ));
#endif
/*
* in ldap_sync.c
*/
/*
* initialize the persistent search structure
*/
LDAP_F( ldap_sync_t * )
ldap_sync_initialize LDAP_P((
ldap_sync_t *ls ));
/*
* destroy the persistent search structure
*/
LDAP_F( void )
ldap_sync_destroy LDAP_P((
ldap_sync_t *ls,
int freeit ));
/*
* initialize a refreshOnly sync
*/
LDAP_F( int )
ldap_sync_init LDAP_P((
ldap_sync_t *ls,
int mode ));
/*
* initialize a refreshOnly sync
*/
LDAP_F( int )
ldap_sync_init_refresh_only LDAP_P((
ldap_sync_t *ls ));
/*
* initialize a refreshAndPersist sync
*/
LDAP_F( int )
ldap_sync_init_refresh_and_persist LDAP_P((
ldap_sync_t *ls ));
/*
* poll for new responses
*/
LDAP_F( int )
ldap_sync_poll LDAP_P((
ldap_sync_t *ls ));
#ifdef LDAP_CONTROL_X_SESSION_TRACKING
/*
* in stctrl.c
*/
LDAP_F( int )
ldap_create_session_tracking_value LDAP_P((
LDAP *ld,
char *sessionSourceIp,
char *sessionSourceName,
char *formatOID,
struct berval *sessionTrackingIdentifier,
struct berval *value ));
LDAP_F( int )
ldap_create_session_tracking LDAP_P((
LDAP *ld,
char *sessionSourceIp,
char *sessionSourceName,
char *formatOID,
struct berval *sessionTrackingIdentifier,
LDAPControl **ctrlp ));
LDAP_F( int )
ldap_parse_session_tracking_control LDAP_P((
LDAP *ld,
LDAPControl *ctrl,
struct berval *ip,
struct berval *name,
struct berval *oid,
struct berval *id ));
#endif /* LDAP_CONTROL_X_SESSION_TRACKING */
/*
* in assertion.c
*/
LDAP_F (int)
ldap_create_assertion_control_value LDAP_P((
LDAP *ld,
char *assertion,
struct berval *value ));
LDAP_F( int )
ldap_create_assertion_control LDAP_P((
LDAP *ld,
char *filter,
int iscritical,
LDAPControl **ctrlp ));
/*
* in deref.c
*/
typedef struct LDAPDerefSpec {
char *derefAttr;
char **attributes;
} LDAPDerefSpec;
typedef struct LDAPDerefVal {
char *type;
BerVarray vals;
struct LDAPDerefVal *next;
} LDAPDerefVal;
typedef struct LDAPDerefRes {
char *derefAttr;
struct berval derefVal;
LDAPDerefVal *attrVals;
struct LDAPDerefRes *next;
} LDAPDerefRes;
LDAP_F( int )
ldap_create_deref_control_value LDAP_P((
LDAP *ld,
LDAPDerefSpec *ds,
struct berval *value ));
LDAP_F( int )
ldap_create_deref_control LDAP_P((
LDAP *ld,
LDAPDerefSpec *ds,
int iscritical,
LDAPControl **ctrlp ));
LDAP_F( void )
ldap_derefresponse_free LDAP_P((
LDAPDerefRes *dr ));
LDAP_F( int )
ldap_parse_derefresponse_control LDAP_P((
LDAP *ld,
LDAPControl *ctrl,
LDAPDerefRes **drp ));
LDAP_F( int )
ldap_parse_deref_control LDAP_P((
LDAP *ld,
LDAPControl **ctrls,
LDAPDerefRes **drp ));
LDAP_END_DECL
#endif /* _LDAP_H */
golang-openldap-0.2/_docs/include/ldap_cdefs.h 0000664 0000000 0000000 00000022372 11766376717 0021424 0 ustar 00root root 0000000 0000000 /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
* Copyright 1998-2012 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* .
*/
/* LDAP C Defines */
#ifndef _LDAP_CDEFS_H
#define _LDAP_CDEFS_H
#if defined(__cplusplus) || defined(c_plusplus)
# define LDAP_BEGIN_DECL extern "C" {
# define LDAP_END_DECL }
#else
# define LDAP_BEGIN_DECL /* begin declarations */
# define LDAP_END_DECL /* end declarations */
#endif
#if !defined(LDAP_NO_PROTOTYPES) && ( defined(LDAP_NEEDS_PROTOTYPES) || \
defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) )
/* ANSI C or C++ */
# define LDAP_P(protos) protos
# define LDAP_CONCAT1(x,y) x ## y
# define LDAP_CONCAT(x,y) LDAP_CONCAT1(x,y)
# define LDAP_STRING(x) #x /* stringify without expanding x */
# define LDAP_XSTRING(x) LDAP_STRING(x) /* expand x, then stringify */
#ifndef LDAP_CONST
# define LDAP_CONST const
#endif
#else /* no prototypes */
/* traditional C */
# define LDAP_P(protos) ()
# define LDAP_CONCAT(x,y) x/**/y
# define LDAP_STRING(x) "x"
#ifndef LDAP_CONST
# define LDAP_CONST /* no const */
#endif
#endif /* no prototypes */
#if (__GNUC__) * 1000 + (__GNUC_MINOR__) >= 2006
# define LDAP_GCCATTR(attrs) __attribute__(attrs)
#else
# define LDAP_GCCATTR(attrs)
#endif
/*
* Support for Windows DLLs.
*
* When external source code includes header files for dynamic libraries,
* the external source code is "importing" DLL symbols into its resulting
* object code. On Windows, symbols imported from DLLs must be explicitly
* indicated in header files with the __declspec(dllimport) directive.
* This is not totally necessary for functions because the compiler
* (gcc or MSVC) will generate stubs when this directive is absent.
* However, this is required for imported variables.
*
* The LDAP libraries, i.e. liblber and libldap, can be built as
* static or shared, based on configuration. Just about all other source
* code in OpenLDAP use these libraries. If the LDAP libraries
* are configured as shared, 'configure' defines the LDAP_LIBS_DYNAMIC
* macro. When other source files include LDAP library headers, the
* LDAP library symbols will automatically be marked as imported. When
* the actual LDAP libraries are being built, the symbols will not
* be marked as imported because the LBER_LIBRARY or LDAP_LIBRARY macros
* will be respectively defined.
*
* Any project outside of OpenLDAP with source code wanting to use
* LDAP dynamic libraries should explicitly define LDAP_LIBS_DYNAMIC.
* This will ensure that external source code appropriately marks symbols
* that will be imported.
*
* The slapd executable, itself, can be used as a dynamic library.
* For example, if a backend module is compiled as shared, it will
* import symbols from slapd. When this happens, the slapd symbols
* must be marked as imported in header files that the backend module
* includes. Remember that slapd links with various static libraries.
* If the LDAP libraries were configured as static, their object
* code is also part of the monolithic slapd executable. Thus, when
* a backend module imports symbols from slapd, it imports symbols from
* all of the static libraries in slapd as well. Thus, the SLAP_IMPORT
* macro, when defined, will appropriately mark symbols as imported.
* This macro should be used by shared backend modules as well as any
* other external source code that imports symbols from the slapd
* executable as if it were a DLL.
*
* Note that we don't actually have to worry about using the
* __declspec(dllexport) directive anywhere. This is because both
* MSVC and Mingw provide alternate (more effective) methods for exporting
* symbols out of binaries, i.e. the use of a DEF file.
*
* NOTE ABOUT BACKENDS: Backends can be configured as static or dynamic.
* When a backend is configured as dynamic, slapd will load the backend
* explicitly and populate function pointer structures by calling
* the backend's well-known initialization function. Because of this
* procedure, slapd never implicitly imports symbols from dynamic backends.
* This makes it unnecessary to tag various backend functions with the
* __declspec(dllimport) directive. This is because neither slapd nor
* any other external binary should ever be implicitly loading a backend
* dynamic module.
*
* Backends are supposed to be self-contained. However, it appears that
* back-meta DOES implicitly import symbols from back-ldap. This means
* that the __declspec(dllimport) directive should be marked on back-ldap
* functions (in its header files) if and only if we're compiling for
* windows AND back-ldap has been configured as dynamic AND back-meta
* is the client of back-ldap. When client is slapd, there is no effect
* since slapd does not implicitly import symbols.
*
* TODO(?): Currently, back-meta nor back-ldap is supported for Mingw32.
* Thus, there's no need to worry about this right now. This is something that
* may or may not have to be addressed in the future.
*/
/* LBER library */
#if defined(_WIN32) && \
((defined(LDAP_LIBS_DYNAMIC) && !defined(LBER_LIBRARY)) || \
(!defined(LDAP_LIBS_DYNAMIC) && defined(SLAPD_IMPORT)))
# define LBER_F(type) extern __declspec(dllimport) type
# define LBER_V(type) extern __declspec(dllimport) type
#else
# define LBER_F(type) extern type
# define LBER_V(type) extern type
#endif
/* LDAP library */
#if defined(_WIN32) && \
((defined(LDAP_LIBS_DYNAMIC) && !defined(LDAP_LIBRARY)) || \
(!defined(LDAP_LIBS_DYNAMIC) && defined(SLAPD_IMPORT)))
# define LDAP_F(type) extern __declspec(dllimport) type
# define LDAP_V(type) extern __declspec(dllimport) type
#else
# define LDAP_F(type) extern type
# define LDAP_V(type) extern type
#endif
/* AVL library */
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define LDAP_AVL_F(type) extern __declspec(dllimport) type
# define LDAP_AVL_V(type) extern __declspec(dllimport) type
#else
# define LDAP_AVL_F(type) extern type
# define LDAP_AVL_V(type) extern type
#endif
/* LDIF library */
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define LDAP_LDIF_F(type) extern __declspec(dllimport) type
# define LDAP_LDIF_V(type) extern __declspec(dllimport) type
#else
# define LDAP_LDIF_F(type) extern type
# define LDAP_LDIF_V(type) extern type
#endif
/* LUNICODE library */
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define LDAP_LUNICODE_F(type) extern __declspec(dllimport) type
# define LDAP_LUNICODE_V(type) extern __declspec(dllimport) type
#else
# define LDAP_LUNICODE_F(type) extern type
# define LDAP_LUNICODE_V(type) extern type
#endif
/* LUTIL library */
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define LDAP_LUTIL_F(type) extern __declspec(dllimport) type
# define LDAP_LUTIL_V(type) extern __declspec(dllimport) type
#else
# define LDAP_LUTIL_F(type) extern type
# define LDAP_LUTIL_V(type) extern type
#endif
/* REWRITE library */
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define LDAP_REWRITE_F(type) extern __declspec(dllimport) type
# define LDAP_REWRITE_V(type) extern __declspec(dllimport) type
#else
# define LDAP_REWRITE_F(type) extern type
# define LDAP_REWRITE_V(type) extern type
#endif
/* SLAPD (as a dynamic library exporting symbols) */
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define LDAP_SLAPD_F(type) extern __declspec(dllimport) type
# define LDAP_SLAPD_V(type) extern __declspec(dllimport) type
#else
# define LDAP_SLAPD_F(type) extern type
# define LDAP_SLAPD_V(type) extern type
#endif
/* SLAPD (as a dynamic library exporting symbols) */
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define LDAP_SLAPI_F(type) extern __declspec(dllimport) type
# define LDAP_SLAPI_V(type) extern __declspec(dllimport) type
#else
# define LDAP_SLAPI_F(type) extern type
# define LDAP_SLAPI_V(type) extern type
#endif
/* SLAPD (as a dynamic library exporting symbols) */
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define SLAPI_F(type) extern __declspec(dllimport) type
# define SLAPI_V(type) extern __declspec(dllimport) type
#else
# define SLAPI_F(type) extern type
# define SLAPI_V(type) extern type
#endif
/*
* C library. Mingw32 links with the dynamic C run-time library by default,
* so the explicit definition of CSTATIC will keep dllimport from
* being defined, if desired.
*
* MSVC defines the _DLL macro when the compiler is invoked with /MD or /MDd,
* which means the resulting object code will be linked with the dynamic
* C run-time library.
*
* Technically, it shouldn't be necessary to redefine any functions that
* the headers for the C library should already contain. Nevertheless, this
* is here as a safe-guard.
*
* TODO: Determine if these macros ever get expanded for Windows. If not,
* the declspec expansion can probably be removed.
*/
#if (defined(__MINGW32__) && !defined(CSTATIC)) || \
(defined(_MSC_VER) && defined(_DLL))
# define LDAP_LIBC_F(type) extern __declspec(dllimport) type
# define LDAP_LIBC_V(type) extern __declspec(dllimport) type
#else
# define LDAP_LIBC_F(type) extern type
# define LDAP_LIBC_V(type) extern type
#endif
#endif /* _LDAP_CDEFS_H */
golang-openldap-0.2/_docs/include/ldap_features.h 0000664 0000000 0000000 00000003426 11766376717 0022155 0 ustar 00root root 0000000 0000000 /* include/ldap_features.h. Generated from ldap_features.hin by configure. */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
* Copyright 1998-2012 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* .
*/
/*
* LDAP Features
*/
#ifndef _LDAP_FEATURES_H
#define _LDAP_FEATURES_H 1
/* OpenLDAP API version macros */
#define LDAP_VENDOR_VERSION 20430
#define LDAP_VENDOR_VERSION_MAJOR 2
#define LDAP_VENDOR_VERSION_MINOR 4
#define LDAP_VENDOR_VERSION_PATCH 30
/*
** WORK IN PROGRESS!
**
** OpenLDAP reentrancy/thread-safeness should be dynamically
** checked using ldap_get_option().
**
** The -lldap implementation is not thread-safe.
**
** The -lldap_r implementation is:
** LDAP_API_FEATURE_THREAD_SAFE (basic thread safety)
** but also be:
** LDAP_API_FEATURE_SESSION_THREAD_SAFE
** LDAP_API_FEATURE_OPERATION_THREAD_SAFE
**
** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
** can be used to determine if -lldap_r is available at compile
** time. You must define LDAP_THREAD_SAFE if and only if you
** link with -lldap_r.
**
** If you fail to define LDAP_THREAD_SAFE when linking with
** -lldap_r or define LDAP_THREAD_SAFE when linking with -lldap,
** provided header definations and declarations may be incorrect.
**
*/
/* is -lldap_r available or not */
#define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 1
/* LDAP v2 Referrals */
/* #undef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
#endif /* LDAP_FEATURES */
golang-openldap-0.2/_docs/include/ldap_schema.h 0000664 0000000 0000000 00000022352 11766376717 0021576 0 ustar 00root root 0000000 0000000 /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
* Copyright 1998-2012 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* .
*/
/* ldap-schema.h - Header for basic schema handling functions that can be
* used by both clients and servers.
* these routines should be renamed ldap_x_...
*/
#ifndef _LDAP_SCHEMA_H
#define _LDAP_SCHEMA_H 1
#include
LDAP_BEGIN_DECL
/* Codes for parsing errors */
#define LDAP_SCHERR_OUTOFMEM 1
#define LDAP_SCHERR_UNEXPTOKEN 2
#define LDAP_SCHERR_NOLEFTPAREN 3
#define LDAP_SCHERR_NORIGHTPAREN 4
#define LDAP_SCHERR_NODIGIT 5
#define LDAP_SCHERR_BADNAME 6
#define LDAP_SCHERR_BADDESC 7
#define LDAP_SCHERR_BADSUP 8
#define LDAP_SCHERR_DUPOPT 9
#define LDAP_SCHERR_EMPTY 10
#define LDAP_SCHERR_MISSING 11
#define LDAP_SCHERR_OUT_OF_ORDER 12
typedef struct ldap_schema_extension_item {
char *lsei_name;
char **lsei_values;
} LDAPSchemaExtensionItem;
typedef struct ldap_syntax {
char *syn_oid; /* REQUIRED */
char **syn_names; /* OPTIONAL */
char *syn_desc; /* OPTIONAL */
LDAPSchemaExtensionItem **syn_extensions; /* OPTIONAL */
} LDAPSyntax;
typedef struct ldap_matchingrule {
char *mr_oid; /* REQUIRED */
char **mr_names; /* OPTIONAL */
char *mr_desc; /* OPTIONAL */
int mr_obsolete; /* OPTIONAL */
char *mr_syntax_oid; /* REQUIRED */
LDAPSchemaExtensionItem **mr_extensions; /* OPTIONAL */
} LDAPMatchingRule;
typedef struct ldap_matchingruleuse {
char *mru_oid; /* REQUIRED */
char **mru_names; /* OPTIONAL */
char *mru_desc; /* OPTIONAL */
int mru_obsolete; /* OPTIONAL */
char **mru_applies_oids; /* REQUIRED */
LDAPSchemaExtensionItem **mru_extensions; /* OPTIONAL */
} LDAPMatchingRuleUse;
typedef struct ldap_attributetype {
char *at_oid; /* REQUIRED */
char **at_names; /* OPTIONAL */
char *at_desc; /* OPTIONAL */
int at_obsolete; /* 0=no, 1=yes */
char *at_sup_oid; /* OPTIONAL */
char *at_equality_oid; /* OPTIONAL */
char *at_ordering_oid; /* OPTIONAL */
char *at_substr_oid; /* OPTIONAL */
char *at_syntax_oid; /* OPTIONAL */
int at_syntax_len; /* OPTIONAL */
int at_single_value; /* 0=no, 1=yes */
int at_collective; /* 0=no, 1=yes */
int at_no_user_mod; /* 0=no, 1=yes */
int at_usage; /* 0=userApplications, 1=directoryOperation,
2=distributedOperation, 3=dSAOperation */
LDAPSchemaExtensionItem **at_extensions; /* OPTIONAL */
} LDAPAttributeType;
typedef struct ldap_objectclass {
char *oc_oid; /* REQUIRED */
char **oc_names; /* OPTIONAL */
char *oc_desc; /* OPTIONAL */
int oc_obsolete; /* 0=no, 1=yes */
char **oc_sup_oids; /* OPTIONAL */
int oc_kind; /* 0=ABSTRACT, 1=STRUCTURAL, 2=AUXILIARY */
char **oc_at_oids_must; /* OPTIONAL */
char **oc_at_oids_may; /* OPTIONAL */
LDAPSchemaExtensionItem **oc_extensions; /* OPTIONAL */
} LDAPObjectClass;
typedef struct ldap_contentrule {
char *cr_oid; /* REQUIRED */
char **cr_names; /* OPTIONAL */
char *cr_desc; /* OPTIONAL */
char **cr_sup_oids; /* OPTIONAL */
int cr_obsolete; /* 0=no, 1=yes */
char **cr_oc_oids_aux; /* OPTIONAL */
char **cr_at_oids_must; /* OPTIONAL */
char **cr_at_oids_may; /* OPTIONAL */
char **cr_at_oids_not; /* OPTIONAL */
LDAPSchemaExtensionItem **cr_extensions; /* OPTIONAL */
} LDAPContentRule;
typedef struct ldap_nameform {
char *nf_oid; /* REQUIRED */
char **nf_names; /* OPTIONAL */
char *nf_desc; /* OPTIONAL */
int nf_obsolete; /* 0=no, 1=yes */
char *nf_objectclass; /* REQUIRED */
char **nf_at_oids_must; /* REQUIRED */
char **nf_at_oids_may; /* OPTIONAL */
LDAPSchemaExtensionItem **nf_extensions; /* OPTIONAL */
} LDAPNameForm;
typedef struct ldap_structurerule {
int sr_ruleid; /* REQUIRED */
char **sr_names; /* OPTIONAL */
char *sr_desc; /* OPTIONAL */
int sr_obsolete; /* 0=no, 1=yes */
char *sr_nameform; /* REQUIRED */
int sr_nsup_ruleids;/* number of sr_sup_ruleids */
int *sr_sup_ruleids;/* OPTIONAL */
LDAPSchemaExtensionItem **sr_extensions; /* OPTIONAL */
} LDAPStructureRule;
/*
* Misc macros
*/
#define LDAP_SCHEMA_NO 0
#define LDAP_SCHEMA_YES 1
#define LDAP_SCHEMA_USER_APPLICATIONS 0
#define LDAP_SCHEMA_DIRECTORY_OPERATION 1
#define LDAP_SCHEMA_DISTRIBUTED_OPERATION 2
#define LDAP_SCHEMA_DSA_OPERATION 3
#define LDAP_SCHEMA_ABSTRACT 0
#define LDAP_SCHEMA_STRUCTURAL 1
#define LDAP_SCHEMA_AUXILIARY 2
/*
* Flags that control how liberal the parsing routines are.
*/
#define LDAP_SCHEMA_ALLOW_NONE 0x00U /* Strict parsing */
#define LDAP_SCHEMA_ALLOW_NO_OID 0x01U /* Allow missing oid */
#define LDAP_SCHEMA_ALLOW_QUOTED 0x02U /* Allow bogus extra quotes */
#define LDAP_SCHEMA_ALLOW_DESCR 0x04U /* Allow descr instead of OID */
#define LDAP_SCHEMA_ALLOW_DESCR_PREFIX 0x08U /* Allow descr as OID prefix */
#define LDAP_SCHEMA_ALLOW_OID_MACRO 0x10U /* Allow OID macros in slapd */
#define LDAP_SCHEMA_ALLOW_OUT_OF_ORDER_FIELDS 0x20U /* Allow fields in most any order */
#define LDAP_SCHEMA_ALLOW_ALL 0x3fU /* Be very liberal in parsing */
#define LDAP_SCHEMA_SKIP 0x80U /* Don't malloc any result */
LDAP_F( LDAP_CONST char * )
ldap_syntax2name LDAP_P((
LDAPSyntax * syn ));
LDAP_F( LDAP_CONST char * )
ldap_matchingrule2name LDAP_P((
LDAPMatchingRule * mr ));
LDAP_F( LDAP_CONST char * )
ldap_matchingruleuse2name LDAP_P((
LDAPMatchingRuleUse * mru ));
LDAP_F( LDAP_CONST char * )
ldap_attributetype2name LDAP_P((
LDAPAttributeType * at ));
LDAP_F( LDAP_CONST char * )
ldap_objectclass2name LDAP_P((
LDAPObjectClass * oc ));
LDAP_F( LDAP_CONST char * )
ldap_contentrule2name LDAP_P((
LDAPContentRule * cr ));
LDAP_F( LDAP_CONST char * )
ldap_nameform2name LDAP_P((
LDAPNameForm * nf ));
LDAP_F( LDAP_CONST char * )
ldap_structurerule2name LDAP_P((
LDAPStructureRule * sr ));
LDAP_F( void )
ldap_syntax_free LDAP_P((
LDAPSyntax * syn ));
LDAP_F( void )
ldap_matchingrule_free LDAP_P((
LDAPMatchingRule * mr ));
LDAP_F( void )
ldap_matchingruleuse_free LDAP_P((
LDAPMatchingRuleUse * mr ));
LDAP_F( void )
ldap_attributetype_free LDAP_P((
LDAPAttributeType * at ));
LDAP_F( void )
ldap_objectclass_free LDAP_P((
LDAPObjectClass * oc ));
LDAP_F( void )
ldap_contentrule_free LDAP_P((
LDAPContentRule * cr ));
LDAP_F( void )
ldap_nameform_free LDAP_P((
LDAPNameForm * nf ));
LDAP_F( void )
ldap_structurerule_free LDAP_P((
LDAPStructureRule * sr ));
LDAP_F( LDAPStructureRule * )
ldap_str2structurerule LDAP_P((
LDAP_CONST char * s,
int * code,
LDAP_CONST char ** errp,
LDAP_CONST unsigned flags ));
LDAP_F( LDAPNameForm * )
ldap_str2nameform LDAP_P((
LDAP_CONST char * s,
int * code,
LDAP_CONST char ** errp,
LDAP_CONST unsigned flags ));
LDAP_F( LDAPContentRule * )
ldap_str2contentrule LDAP_P((
LDAP_CONST char * s,
int * code,
LDAP_CONST char ** errp,
LDAP_CONST unsigned flags ));
LDAP_F( LDAPObjectClass * )
ldap_str2objectclass LDAP_P((
LDAP_CONST char * s,
int * code,
LDAP_CONST char ** errp,
LDAP_CONST unsigned flags ));
LDAP_F( LDAPAttributeType * )
ldap_str2attributetype LDAP_P((
LDAP_CONST char * s,
int * code,
LDAP_CONST char ** errp,
LDAP_CONST unsigned flags ));
LDAP_F( LDAPSyntax * )
ldap_str2syntax LDAP_P((
LDAP_CONST char * s,
int * code,
LDAP_CONST char ** errp,
LDAP_CONST unsigned flags ));
LDAP_F( LDAPMatchingRule * )
ldap_str2matchingrule LDAP_P((
LDAP_CONST char * s,
int * code,
LDAP_CONST char ** errp,
LDAP_CONST unsigned flags ));
LDAP_F( LDAPMatchingRuleUse * )
ldap_str2matchingruleuse LDAP_P((
LDAP_CONST char * s,
int * code,
LDAP_CONST char ** errp,
LDAP_CONST unsigned flags ));
LDAP_F( char * )
ldap_structurerule2str LDAP_P((
LDAPStructureRule * sr ));
LDAP_F( struct berval * )
ldap_structurerule2bv LDAP_P((
LDAPStructureRule * sr, struct berval *bv ));
LDAP_F( char * )
ldap_nameform2str LDAP_P((
LDAPNameForm * nf ));
LDAP_F( struct berval * )
ldap_nameform2bv LDAP_P((
LDAPNameForm * nf, struct berval *bv ));
LDAP_F( char * )
ldap_contentrule2str LDAP_P((
LDAPContentRule * cr ));
LDAP_F( struct berval * )
ldap_contentrule2bv LDAP_P((
LDAPContentRule * cr, struct berval *bv ));
LDAP_F( char * )
ldap_objectclass2str LDAP_P((
LDAPObjectClass * oc ));
LDAP_F( struct berval * )
ldap_objectclass2bv LDAP_P((
LDAPObjectClass * oc, struct berval *bv ));
LDAP_F( char * )
ldap_attributetype2str LDAP_P((
LDAPAttributeType * at ));
LDAP_F( struct berval * )
ldap_attributetype2bv LDAP_P((
LDAPAttributeType * at, struct berval *bv ));
LDAP_F( char * )
ldap_syntax2str LDAP_P((
LDAPSyntax * syn ));
LDAP_F( struct berval * )
ldap_syntax2bv LDAP_P((
LDAPSyntax * syn, struct berval *bv ));
LDAP_F( char * )
ldap_matchingrule2str LDAP_P((
LDAPMatchingRule * mr ));
LDAP_F( struct berval * )
ldap_matchingrule2bv LDAP_P((
LDAPMatchingRule * mr, struct berval *bv ));
LDAP_F( char * )
ldap_matchingruleuse2str LDAP_P((
LDAPMatchingRuleUse * mru ));
LDAP_F( struct berval * )
ldap_matchingruleuse2bv LDAP_P((
LDAPMatchingRuleUse * mru, struct berval *bv ));
LDAP_F( char * )
ldap_scherr2str LDAP_P((
int code )) LDAP_GCCATTR((const));
LDAP_END_DECL
#endif
golang-openldap-0.2/_docs/include/ldap_utf8.h 0000664 0000000 0000000 00000006614 11766376717 0021227 0 ustar 00root root 0000000 0000000 /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
* Copyright 1998-2012 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* .
*/
/* This notice applies to changes, created by or for Novell, Inc.,
* to preexisting works for which notices appear elsewhere in this file.
*
* Copyright (C) 2000 Novell, Inc. All Rights Reserved.
*
* THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES.
* USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO VERSION
* 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS AVAILABLE AT
* HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE" IN THE
* TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION OF THIS
* WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP PUBLIC
* LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT THE
* PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
*/
/* Note: A verbatim copy of version 2.0.1 of the OpenLDAP Public License
* can be found in the file "build/LICENSE-2.0.1" in this distribution
* of OpenLDAP Software.
*/
#ifndef _LDAP_UTF8_H
#define _LDAP_UTF8_H
#include /* get ber_*_t */
/*
* UTF-8 Utility Routines
*/
LDAP_BEGIN_DECL
#define LDAP_UCS4_INVALID (0x80000000U)
typedef ber_int_t ldap_ucs4_t;
/* LDAP_MAX_UTF8_LEN is 3 or 6 depending on size of wchar_t */
#define LDAP_MAX_UTF8_LEN ( sizeof(wchar_t) * 3/2 )
/* Unicode conversion routines */
LDAP_F( ldap_ucs4_t ) ldap_x_utf8_to_ucs4( LDAP_CONST char * p );
LDAP_F( int ) ldap_x_ucs4_to_utf8( ldap_ucs4_t c, char *buf );
/*
* Wide Char / UTF-8 Conversion Routines
*/
/* UTF-8 character to Wide Char */
LDAP_F(int) ldap_x_utf8_to_wc LDAP_P((
wchar_t *wchar, LDAP_CONST char *utf8char ));
/* UTF-8 string to Wide Char string */
LDAP_F(int) ldap_x_utf8s_to_wcs LDAP_P((
wchar_t *wcstr, LDAP_CONST char *utf8str, size_t count ));
/* Wide Char to UTF-8 character */
LDAP_F(int) ldap_x_wc_to_utf8 LDAP_P((
char *utf8char, wchar_t wchar, size_t count ));
/* Wide Char string to UTF-8 string */
LDAP_F(int) ldap_x_wcs_to_utf8s LDAP_P((
char *utf8str, LDAP_CONST wchar_t *wcstr, size_t count ));
/*
* MultiByte Char / UTF-8 Conversion Routines
*/
/* UTF-8 character to MultiByte character */
LDAP_F(int) ldap_x_utf8_to_mb LDAP_P((
char *mbchar, LDAP_CONST char *utf8char,
int (*ldap_f_wctomb)( char *mbchar, wchar_t wchar )));
/* UTF-8 string to MultiByte string */
LDAP_F(int) ldap_x_utf8s_to_mbs LDAP_P((
char *mbstr, LDAP_CONST char *utf8str, size_t count,
size_t (*ldap_f_wcstombs)( char *mbstr,
LDAP_CONST wchar_t *wcstr, size_t count) ));
/* MultiByte character to UTF-8 character */
LDAP_F(int) ldap_x_mb_to_utf8 LDAP_P((
char *utf8char, LDAP_CONST char *mbchar, size_t mbsize,
int (*ldap_f_mbtowc)( wchar_t *wchar,
LDAP_CONST char *mbchar, size_t count) ));
/* MultiByte string to UTF-8 string */
LDAP_F(int) ldap_x_mbs_to_utf8s LDAP_P((
char *utf8str, LDAP_CONST char *mbstr, size_t count,
size_t (*ldap_f_mbstowcs)( wchar_t *wcstr,
LDAP_CONST char *mbstr, size_t count) ));
LDAP_END_DECL
#endif /* _LDAP_UTF8_H */
golang-openldap-0.2/_docs/include/ldif.h 0000664 0000000 0000000 00000011102 11766376717 0020243 0 ustar 00root root 0000000 0000000 /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
* Copyright 1998-2012 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* .
*/
/* Portions Copyright (c) 1996 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
#ifndef _LDIF_H
#define _LDIF_H
#include
LDAP_BEGIN_DECL
/* This is NOT a bogus extern declaration (unlike ldap_debug) */
LDAP_LDIF_V (int) ldif_debug;
#define LDIF_LINE_WIDTH 76 /* default maximum length of LDIF lines */
#define LDIF_LINE_WIDTH_MAX ((ber_len_t)-1) /* maximum length of LDIF lines */
#define LDIF_LINE_WIDTH_WRAP(wrap) ((wrap) == 0 ? LDIF_LINE_WIDTH : (wrap))
/*
* Macro to calculate maximum number of bytes that the base64 equivalent
* of an item that is "len" bytes long will take up. Base64 encoding
* uses one byte for every six bits in the value plus up to two pad bytes.
*/
#define LDIF_BASE64_LEN(len) (((len) * 4 / 3 ) + 3)
/*
* Macro to calculate maximum size that an LDIF-encoded type (length
* tlen) and value (length vlen) will take up: room for type + ":: " +
* first newline + base64 value + continued lines. Each continued line
* needs room for a newline and a leading space character.
*/
#define LDIF_SIZE_NEEDED(nlen,vlen) \
((nlen) + 4 + LDIF_BASE64_LEN(vlen) \
+ ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / LDIF_LINE_WIDTH * 2 ))
#define LDIF_SIZE_NEEDED_WRAP(nlen,vlen,wrap) \
((nlen) + 4 + LDIF_BASE64_LEN(vlen) \
+ ((wrap) == 0 ? ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / ( LDIF_LINE_WIDTH ) * 2 ) : \
((wrap) == LDIF_LINE_WIDTH_MAX ? 0 : ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / (wrap) * 2 ))))
LDAP_LDIF_F( int )
ldif_parse_line LDAP_P((
LDAP_CONST char *line,
char **name,
char **value,
ber_len_t *vlen ));
LDAP_LDIF_F( int )
ldif_parse_line2 LDAP_P((
char *line,
struct berval *type,
struct berval *value,
int *freeval ));
LDAP_LDIF_F( FILE * )
ldif_open_url LDAP_P(( LDAP_CONST char *urlstr ));
LDAP_LDIF_F( int )
ldif_fetch_url LDAP_P((
LDAP_CONST char *line,
char **value,
ber_len_t *vlen ));
LDAP_LDIF_F( char * )
ldif_getline LDAP_P(( char **next ));
LDAP_LDIF_F( int )
ldif_countlines LDAP_P(( LDAP_CONST char *line ));
/* ldif_ropen, rclose, read_record - just for reading LDIF files,
* no special open/close needed to write LDIF files.
*/
typedef struct LDIFFP {
FILE *fp;
struct LDIFFP *prev;
} LDIFFP;
LDAP_LDIF_F( LDIFFP * )
ldif_open LDAP_P(( LDAP_CONST char *file, LDAP_CONST char *mode ));
LDAP_LDIF_F( void )
ldif_close LDAP_P(( LDIFFP * ));
LDAP_LDIF_F( int )
ldif_read_record LDAP_P((
LDIFFP *fp,
int *lineno,
char **bufp,
int *buflen ));
LDAP_LDIF_F( int )
ldif_must_b64_encode_register LDAP_P((
LDAP_CONST char *name,
LDAP_CONST char *oid ));
LDAP_LDIF_F( void )
ldif_must_b64_encode_release LDAP_P(( void ));
#define LDIF_PUT_NOVALUE 0x0000 /* no value */
#define LDIF_PUT_VALUE 0x0001 /* value w/ auto detection */
#define LDIF_PUT_TEXT 0x0002 /* assume text */
#define LDIF_PUT_BINARY 0x0004 /* assume binary (convert to base64) */
#define LDIF_PUT_B64 0x0008 /* pre-converted base64 value */
#define LDIF_PUT_COMMENT 0x0010 /* comment */
#define LDIF_PUT_URL 0x0020 /* url */
#define LDIF_PUT_SEP 0x0040 /* separator */
LDAP_LDIF_F( void )
ldif_sput LDAP_P((
char **out,
int type,
LDAP_CONST char *name,
LDAP_CONST char *val,
ber_len_t vlen ));
LDAP_LDIF_F( void )
ldif_sput_wrap LDAP_P((
char **out,
int type,
LDAP_CONST char *name,
LDAP_CONST char *val,
ber_len_t vlen,
ber_len_t wrap ));
LDAP_LDIF_F( char * )
ldif_put LDAP_P((
int type,
LDAP_CONST char *name,
LDAP_CONST char *val,
ber_len_t vlen ));
LDAP_LDIF_F( char * )
ldif_put_wrap LDAP_P((
int type,
LDAP_CONST char *name,
LDAP_CONST char *val,
ber_len_t vlen,
ber_len_t wrap ));
LDAP_LDIF_F( int )
ldif_is_not_printable LDAP_P((
LDAP_CONST char *val,
ber_len_t vlen ));
LDAP_END_DECL
#endif /* _LDIF_H */
golang-openldap-0.2/_docs/include/slapi-plugin.h 0000664 0000000 0000000 00000112547 11766376717 0021750 0 ustar 00root root 0000000 0000000 /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
* Copyright 1998-2012 The OpenLDAP Foundation.
* Portions Copyright 1997,2002,2003 IBM Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* .
*/
/*
* This header is used in development of SLAPI plugins for
* OpenLDAP slapd(8) and other directory servers supporting
* this interface. Your portability mileage may vary.
*/
#ifndef _SLAPI_PLUGIN_H
#define _SLAPI_PLUGIN_H
#include
typedef struct slapi_pblock Slapi_PBlock;
typedef struct slapi_entry Slapi_Entry;
typedef struct slapi_attr Slapi_Attr;
typedef struct slapi_value Slapi_Value;
typedef struct slapi_valueset Slapi_ValueSet;
typedef struct slapi_filter Slapi_Filter;
typedef struct BackendDB Slapi_Backend;
typedef struct Operation Slapi_Operation;
typedef struct Connection Slapi_Connection;
typedef struct slapi_dn Slapi_DN;
typedef struct slapi_rdn Slapi_RDN;
typedef struct slapi_mod Slapi_Mod;
typedef struct slapi_mods Slapi_Mods;
typedef struct slapi_componentid Slapi_ComponentId;
#define SLAPI_ATTR_UNIQUEID "entryUUID"
#define SLAPI_ATTR_OBJECTCLASS "objectClass"
/* pblock routines */
int slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value );
int slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value );
Slapi_PBlock *slapi_pblock_new( void );
void slapi_pblock_destroy( Slapi_PBlock *pb );
/* entry/attr/dn routines */
Slapi_Entry *slapi_str2entry( char *s, int flags );
#define SLAPI_STR2ENTRY_REMOVEDUPVALS 1
#define SLAPI_STR2ENTRY_ADDRDNVALS 2
#define SLAPI_STR2ENTRY_BIGENTRY 4
#define SLAPI_STR2ENTRY_TOMBSTONE_CHECK 8
#define SLAPI_STR2ENTRY_IGNORE_STATE 16
#define SLAPI_STR2ENTRY_INCLUDE_VERSION_STR 32
#define SLAPI_STR2ENTRY_EXPAND_OBJECTCLASSES 64
#define SLAPI_STR2ENTRY_NOT_WELL_FORMED_LDIF 128
char *slapi_entry2str( Slapi_Entry *e, int *len );
char *slapi_entry_get_dn( Slapi_Entry *e );
int slapi_x_entry_get_id( Slapi_Entry *e );
void slapi_entry_set_dn( Slapi_Entry *e, char *dn );
Slapi_Entry *slapi_entry_dup( Slapi_Entry *e );
int slapi_entry_attr_delete( Slapi_Entry *e, char *type );
Slapi_Entry *slapi_entry_alloc();
void slapi_entry_free( Slapi_Entry *e );
int slapi_entry_attr_merge( Slapi_Entry *e, char *type, struct berval **vals );
int slapi_entry_attr_find( Slapi_Entry *e, char *type, Slapi_Attr **attr );
char *slapi_entry_attr_get_charptr( const Slapi_Entry *e, const char *type );
int slapi_entry_attr_get_int( const Slapi_Entry *e, const char *type );
long slapi_entry_attr_get_long( const Slapi_Entry *e, const char *type );
unsigned int slapi_entry_attr_get_uint( const Slapi_Entry *e, const char *type );
unsigned long slapi_entry_attr_get_ulong( const Slapi_Entry *e, const char *type );
int slapi_attr_get_values( Slapi_Attr *attr, struct berval ***vals );
char *slapi_dn_normalize( char *dn );
char *slapi_dn_normalize_case( char *dn );
int slapi_dn_issuffix( char *dn, char *suffix );
char *slapi_dn_beparent( Slapi_PBlock *pb, const char *dn );
int slapi_dn_isbesuffix( Slapi_PBlock *pb, char *dn );
char *slapi_dn_parent( const char *dn );
int slapi_dn_isparent( const char *parentdn, const char *childdn );
char *slapi_dn_ignore_case( char *dn );
int slapi_rdn2typeval( char *rdn, char **type, struct berval *bv );
char *slapi_dn_plus_rdn(const char *dn, const char *rdn);
/* DS 5.x SLAPI */
int slapi_access_allowed( Slapi_PBlock *pb, Slapi_Entry *e, char *attr, struct berval *val, int access );
int slapi_acl_check_mods( Slapi_PBlock *pb, Slapi_Entry *e, LDAPMod **mods, char **errbuf );
Slapi_Attr *slapi_attr_new( void );
Slapi_Attr *slapi_attr_init( Slapi_Attr *a, const char *type );
void slapi_attr_free( Slapi_Attr **a );
Slapi_Attr *slapi_attr_dup( const Slapi_Attr *attr );
int slapi_attr_add_value( Slapi_Attr *a, const Slapi_Value *v );
int slapi_attr_type2plugin( const char *type, void **pi );
int slapi_attr_get_type( const Slapi_Attr *attr, char **type );
int slapi_attr_get_oid_copy( const Slapi_Attr *attr, char **oidp );
int slapi_attr_get_flags( const Slapi_Attr *attr, unsigned long *flags );
int slapi_attr_flag_is_set( const Slapi_Attr *attr, unsigned long flag );
int slapi_attr_value_cmp( const Slapi_Attr *attr, const struct berval *v1, const struct berval *v2 );
int slapi_attr_value_find( const Slapi_Attr *a, struct berval *v );
#define SLAPI_TYPE_CMP_EXACT 0
#define SLAPI_TYPE_CMP_BASE 1
#define SLAPI_TYPE_CMP_SUBTYPE 2
int slapi_attr_type_cmp( const char *t1, const char *t2, int opt );
int slapi_attr_types_equivalent( const char *t1, const char *t2 );
int slapi_attr_first_value( Slapi_Attr *a, Slapi_Value **v );
int slapi_attr_next_value( Slapi_Attr *a, int hint, Slapi_Value **v );
int slapi_attr_get_numvalues( const Slapi_Attr *a, int *numValues );
int slapi_attr_get_valueset( const Slapi_Attr *a, Slapi_ValueSet **vs );
int slapi_attr_get_bervals_copy( Slapi_Attr *a, struct berval ***vals );
int slapi_entry_attr_hasvalue( Slapi_Entry *e, const char *type, const char *value );
int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
void slapi_entry_attr_set_charptr(Slapi_Entry* e, const char *type, const char *value);
void slapi_entry_attr_set_int( Slapi_Entry* e, const char *type, int l);
void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigned int l);
void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l);
void slapi_entry_attr_set_ulong(Slapi_Entry* e, const char *type, unsigned long l);
int slapi_entry_has_children(const Slapi_Entry *e);
size_t slapi_entry_size(Slapi_Entry *e);
int slapi_is_rootdse( const char *dn );
int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
int slapi_entry_add_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
int slapi_entry_add_valueset(Slapi_Entry *e, const char *type, Slapi_ValueSet *vs);
int slapi_entry_delete_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
int slapi_entry_merge_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
int slapi_entry_attr_replace_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
int slapi_entry_add_value(Slapi_Entry *e, const char *type, const Slapi_Value *value);
int slapi_entry_add_string(Slapi_Entry *e, const char *type, const char *value);
int slapi_entry_delete_string(Slapi_Entry *e, const char *type, const char *value);
int slapi_entry_first_attr( const Slapi_Entry *e, Slapi_Attr **attr );
int slapi_entry_next_attr( const Slapi_Entry *e, Slapi_Attr *prevattr, Slapi_Attr **attr );
const char *slapi_entry_get_uniqueid( const Slapi_Entry *e );
void slapi_entry_set_uniqueid( Slapi_Entry *e, char *uniqueid );
int slapi_entry_schema_check( Slapi_PBlock *pb, Slapi_Entry *e );
int slapi_entry_rdn_values_present( const Slapi_Entry *e );
int slapi_entry_add_rdn_values( Slapi_Entry *e );
char *slapi_attr_syntax_normalize( const char *s );
Slapi_Value *slapi_value_new( void );
Slapi_Value *slapi_value_new_berval(const struct berval *bval);
Slapi_Value *slapi_value_new_value(const Slapi_Value *v);
Slapi_Value *slapi_value_new_string(const char *s);
Slapi_Value *slapi_value_init(Slapi_Value *v);
Slapi_Value *slapi_value_init_berval(Slapi_Value *v, struct berval *bval);
Slapi_Value *slapi_value_init_string(Slapi_Value *v, const char *s);
Slapi_Value *slapi_value_dup(const Slapi_Value *v);
void slapi_value_free(Slapi_Value **value);
const struct berval *slapi_value_get_berval( const Slapi_Value *value );
Slapi_Value *slapi_value_set_berval( Slapi_Value *value, const struct berval *bval );
Slapi_Value *slapi_value_set_value( Slapi_Value *value, const Slapi_Value *vfrom);
Slapi_Value *slapi_value_set( Slapi_Value *value, void *val, unsigned long len);
int slapi_value_set_string(Slapi_Value *value, const char *strVal);
int slapi_value_set_int(Slapi_Value *value, int intVal);
const char*slapi_value_get_string(const Slapi_Value *value);
int slapi_value_get_int(const Slapi_Value *value);
unsigned int slapi_value_get_uint(const Slapi_Value *value);
long slapi_value_get_long(const Slapi_Value *value);
unsigned long slapi_value_get_ulong(const Slapi_Value *value);
size_t slapi_value_get_length(const Slapi_Value *value);
int slapi_value_compare(const Slapi_Attr *a, const Slapi_Value *v1, const Slapi_Value *v2);
Slapi_ValueSet *slapi_valueset_new( void );
void slapi_valueset_free(Slapi_ValueSet *vs);
void slapi_valueset_init(Slapi_ValueSet *vs);
void slapi_valueset_done(Slapi_ValueSet *vs);
void slapi_valueset_add_value(Slapi_ValueSet *vs, const Slapi_Value *addval);
int slapi_valueset_first_value( Slapi_ValueSet *vs, Slapi_Value **v );
int slapi_valueset_next_value( Slapi_ValueSet *vs, int index, Slapi_Value **v);
int slapi_valueset_count( const Slapi_ValueSet *vs);
void slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
/* DNs */
Slapi_DN *slapi_sdn_new( void );
Slapi_DN *slapi_sdn_new_dn_byval( const char *dn );
Slapi_DN *slapi_sdn_new_ndn_byval( const char *ndn );
Slapi_DN *slapi_sdn_new_dn_byref( const char *dn );
Slapi_DN *slapi_sdn_new_ndn_byref( const char *ndn );
Slapi_DN *slapi_sdn_new_dn_passin( const char *dn );
Slapi_DN *slapi_sdn_set_dn_byval( Slapi_DN *sdn, const char *dn );
Slapi_DN *slapi_sdn_set_dn_byref( Slapi_DN *sdn, const char *dn );
Slapi_DN *slapi_sdn_set_dn_passin( Slapi_DN *sdn, const char *dn );
Slapi_DN *slapi_sdn_set_ndn_byval( Slapi_DN *sdn, const char *ndn );
Slapi_DN *slapi_sdn_set_ndn_byref( Slapi_DN *sdn, const char *ndn );
void slapi_sdn_done( Slapi_DN *sdn );
void slapi_sdn_free( Slapi_DN **sdn );
const char * slapi_sdn_get_dn( const Slapi_DN *sdn );
const char * slapi_sdn_get_ndn( const Slapi_DN *sdn );
void slapi_sdn_get_parent( const Slapi_DN *sdn,Slapi_DN *sdn_parent );
void slapi_sdn_get_backend_parent( const Slapi_DN *sdn, Slapi_DN *sdn_parent, const Slapi_Backend *backend );
Slapi_DN * slapi_sdn_dup( const Slapi_DN *sdn );
void slapi_sdn_copy( const Slapi_DN *from, Slapi_DN *to );
int slapi_sdn_compare( const Slapi_DN *sdn1, const Slapi_DN *sdn2 );
int slapi_sdn_isempty( const Slapi_DN *sdn );
int slapi_sdn_issuffix(const Slapi_DN *sdn, const Slapi_DN *suffixsdn );
int slapi_sdn_isparent( const Slapi_DN *parent, const Slapi_DN *child );
int slapi_sdn_isgrandparent( const Slapi_DN *parent, const Slapi_DN *child );
int slapi_sdn_get_ndn_len( const Slapi_DN *sdn );
int slapi_sdn_scope_test( const Slapi_DN *dn, const Slapi_DN *base, int scope );
void slapi_sdn_get_rdn( const Slapi_DN *sdn,Slapi_RDN *rdn );
Slapi_DN *slapi_sdn_set_rdn( Slapi_DN *sdn, const Slapi_RDN *rdn );
Slapi_DN *slapi_sdn_set_parent( Slapi_DN *sdn, const Slapi_DN *parentdn );
int slapi_sdn_is_rdn_component( const Slapi_DN *rdn, const Slapi_Attr *a, const Slapi_Value *v );
char * slapi_moddn_get_newdn( Slapi_DN *dn_olddn, char *newrdn, char *newsuperiordn );
/* RDNs */
Slapi_RDN *slapi_rdn_new( void );
Slapi_RDN *slapi_rdn_new_dn( const char *dn );
Slapi_RDN *slapi_rdn_new_sdn( const Slapi_DN *sdn );
Slapi_RDN *slapi_rdn_new_rdn( const Slapi_RDN *fromrdn );
void slapi_rdn_init( Slapi_RDN *rdn );
void slapi_rdn_init_dn( Slapi_RDN *rdn, const char *dn );
void slapi_rdn_init_sdn( Slapi_RDN *rdn, const Slapi_DN *sdn );
void slapi_rdn_init_rdn( Slapi_RDN *rdn, const Slapi_RDN *fromrdn );
void slapi_rdn_set_dn( Slapi_RDN *rdn, const char *dn );
void slapi_rdn_set_sdn( Slapi_RDN *rdn, const Slapi_DN *sdn );
void slapi_rdn_set_rdn( Slapi_RDN *rdn, const Slapi_RDN *fromrdn );
void slapi_rdn_free( Slapi_RDN **rdn );
void slapi_rdn_done( Slapi_RDN *rdn );
int slapi_rdn_get_first( Slapi_RDN *rdn, char **type, char **value );
int slapi_rdn_get_next( Slapi_RDN *rdn, int index, char **type, char **value );
int slapi_rdn_get_index( Slapi_RDN *rdn, const char *type, const char *value, size_t length );
int slapi_rdn_get_index_attr( Slapi_RDN *rdn, const char *type, char **value );
int slapi_rdn_contains( Slapi_RDN *rdn, const char *type, const char *value,size_t length );
int slapi_rdn_contains_attr( Slapi_RDN *rdn, const char *type, char **value );
int slapi_rdn_add( Slapi_RDN *rdn, const char *type, const char *value );
int slapi_rdn_remove_index( Slapi_RDN *rdn, int atindex );
int slapi_rdn_remove( Slapi_RDN *rdn, const char *type, const char *value, size_t length );
int slapi_rdn_remove_attr( Slapi_RDN *rdn, const char *type );
int slapi_rdn_isempty( const Slapi_RDN *rdn );
int slapi_rdn_get_num_components( Slapi_RDN *rdn );
int slapi_rdn_compare( Slapi_RDN *rdn1, Slapi_RDN *rdn2 );
const char *slapi_rdn_get_rdn( const Slapi_RDN *rdn );
const char *slapi_rdn_get_nrdn( const Slapi_RDN *rdn );
Slapi_DN *slapi_sdn_add_rdn( Slapi_DN *sdn, const Slapi_RDN *rdn );
/* locks and synchronization */
typedef struct slapi_mutex Slapi_Mutex;
typedef struct slapi_condvar Slapi_CondVar;
Slapi_Mutex *slapi_new_mutex( void );
void slapi_destroy_mutex( Slapi_Mutex *mutex );
void slapi_lock_mutex( Slapi_Mutex *mutex );
int slapi_unlock_mutex( Slapi_Mutex *mutex );
Slapi_CondVar *slapi_new_condvar( Slapi_Mutex *mutex );
void slapi_destroy_condvar( Slapi_CondVar *cvar );
int slapi_wait_condvar( Slapi_CondVar *cvar, struct timeval *timeout );
int slapi_notify_condvar( Slapi_CondVar *cvar, int notify_all );
/* thread-safe LDAP connections */
LDAP *slapi_ldap_init( char *ldaphost, int ldapport, int secure, int shared );
void slapi_ldap_unbind( LDAP *ld );
char *slapi_ch_malloc( unsigned long size );
void slapi_ch_free( void **ptr );
void slapi_ch_free_string( char **ptr );
char *slapi_ch_calloc( unsigned long nelem, unsigned long size );
char *slapi_ch_realloc( char *block, unsigned long size );
char *slapi_ch_strdup( const char *s );
void slapi_ch_array_free( char **arrayp );
struct berval *slapi_ch_bvdup(const struct berval *v);
struct berval **slapi_ch_bvecdup(const struct berval **v);
/* LDAP V3 routines */
int slapi_control_present( LDAPControl **controls, char *oid,
struct berval **val, int *iscritical);
void slapi_register_supported_control(char *controloid,
unsigned long controlops);
#define SLAPI_OPERATION_BIND 0x00000001L
#define SLAPI_OPERATION_UNBIND 0x00000002L
#define SLAPI_OPERATION_SEARCH 0x00000004L
#define SLAPI_OPERATION_MODIFY 0x00000008L
#define SLAPI_OPERATION_ADD 0x00000010L
#define SLAPI_OPERATION_DELETE 0x00000020L
#define SLAPI_OPERATION_MODDN 0x00000040L
#define SLAPI_OPERATION_MODRDN SLAPI_OPERATION_MODDN
#define SLAPI_OPERATION_COMPARE 0x00000080L
#define SLAPI_OPERATION_ABANDON 0x00000100L
#define SLAPI_OPERATION_EXTENDED 0x00000200L
#define SLAPI_OPERATION_ANY 0xFFFFFFFFL
#define SLAPI_OPERATION_NONE 0x00000000L
int slapi_get_supported_controls(char ***ctrloidsp, unsigned long **ctrlopsp);
LDAPControl *slapi_dup_control(LDAPControl *ctrl);
void slapi_register_supported_saslmechanism(char *mechanism);
char **slapi_get_supported_saslmechanisms();
char **slapi_get_supported_extended_ops(void);
/* operation */
int slapi_op_abandoned( Slapi_PBlock *pb );
unsigned long slapi_op_get_type(Slapi_Operation * op);
void slapi_operation_set_flag(Slapi_Operation *op, unsigned long flag);
void slapi_operation_clear_flag(Slapi_Operation *op, unsigned long flag);
int slapi_operation_is_flag_set(Slapi_Operation *op, unsigned long flag);
char *slapi_op_type_to_string(unsigned long type);
/* send ldap result back */
void slapi_send_ldap_result( Slapi_PBlock *pb, int err, char *matched,
char *text, int nentries, struct berval **urls );
int slapi_send_ldap_search_entry( Slapi_PBlock *pb, Slapi_Entry *e,
LDAPControl **ectrls, char **attrs, int attrsonly );
int slapi_send_ldap_search_reference( Slapi_PBlock *pb, Slapi_Entry *e,
struct berval **urls, LDAPControl **ectrls, struct berval **v2refs );
/* filter routines */
Slapi_Filter *slapi_str2filter( char *str );
Slapi_Filter *slapi_filter_dup( Slapi_Filter *f );
void slapi_filter_free( Slapi_Filter *f, int recurse );
int slapi_filter_get_choice( Slapi_Filter *f);
int slapi_filter_get_ava( Slapi_Filter *f, char **type, struct berval **bval );
Slapi_Filter *slapi_filter_list_first( Slapi_Filter *f );
Slapi_Filter *slapi_filter_list_next( Slapi_Filter *f, Slapi_Filter *fprev );
int slapi_filter_get_attribute_type( Slapi_Filter *f, char **type );
int slapi_x_filter_set_attribute_type( Slapi_Filter *f, const char *type );
int slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial,
char ***any, char **final );
Slapi_Filter *slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2);
int slapi_x_filter_append( int choice, Slapi_Filter **pContainingFilter,
Slapi_Filter **pNextFilter, Slapi_Filter *filterToAppend );
int slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
int verify_access );
int slapi_filter_test_simple( Slapi_Entry *e, Slapi_Filter *f );
typedef int (*FILTER_APPLY_FN)( Slapi_Filter *f, void *arg );
int slapi_filter_apply( Slapi_Filter *f, FILTER_APPLY_FN fn, void *arg, int *error_code );
#define SLAPI_FILTER_SCAN_STOP -1 /* set by callback */
#define SLAPI_FILTER_SCAN_ERROR -2 /* set by callback */
#define SLAPI_FILTER_SCAN_NOMORE 0 /* set by callback */
#define SLAPI_FILTER_SCAN_CONTINUE 1 /* set by callback */
#define SLAPI_FILTER_UNKNOWN_FILTER_TYPE 2 /* set by slapi_filter_apply() */
/* internal add/delete/search/modify routines */
Slapi_PBlock *slapi_search_internal( char *base, int scope, char *filter,
LDAPControl **controls, char **attrs, int attrsonly );
Slapi_PBlock *slapi_modify_internal( char *dn, LDAPMod **mods,
LDAPControl **controls, int log_change );
Slapi_PBlock *slapi_add_internal( char * dn, LDAPMod **attrs,
LDAPControl **controls, int log_changes );
Slapi_PBlock *slapi_add_entry_internal( Slapi_Entry * e,
LDAPControl **controls, int log_change );
Slapi_PBlock *slapi_delete_internal( char * dn, LDAPControl **controls,
int log_change );
Slapi_PBlock *slapi_modrdn_internal( char * olddn, char * newrdn,
int deloldrdn, LDAPControl **controls,
int log_change );
Slapi_PBlock *slapi_rename_internal( const char * olddn, const char *newrdn,
const char *newsuperior, int delolrdn,
LDAPControl **controls, int log_change );
void slapi_free_search_results_internal(Slapi_PBlock *pb);
/* new internal add/delete/search/modify routines */
typedef void (*plugin_result_callback)( int rc, void *callback_data );
typedef int (*plugin_referral_entry_callback)( char * referral,
void *callback_data );
typedef int (*plugin_search_entry_callback)( Slapi_Entry *e,
void *callback_data );
void slapi_free_search_results_internal( Slapi_PBlock *pb );
#define SLAPI_OP_FLAG_NEVER_CHAIN 0x0800
int slapi_search_internal_pb( Slapi_PBlock *pb );
int slapi_search_internal_callback_pb( Slapi_PBlock *pb, void *callback_data,
plugin_result_callback prc, plugin_search_entry_callback psec,
plugin_referral_entry_callback prec );
int slapi_add_internal_pb( Slapi_PBlock *pb );
int slapi_modify_internal_pb( Slapi_PBlock *pb );
int slapi_modrdn_internal_pb( Slapi_PBlock *pb );
int slapi_delete_internal_pb( Slapi_PBlock *pb );
int slapi_seq_internal_callback_pb(Slapi_PBlock *pb, void *callback_data,
plugin_result_callback res_callback,
plugin_search_entry_callback srch_callback,
plugin_referral_entry_callback ref_callback);
void slapi_search_internal_set_pb( Slapi_PBlock *pb, const char *base,
int scope, const char *filter, char **attrs, int attrsonly,
LDAPControl **controls, const char *uniqueid,
Slapi_ComponentId *plugin_identity, int operation_flags );
void slapi_add_entry_internal_set_pb( Slapi_PBlock *pb, Slapi_Entry *e,
LDAPControl **controls, Slapi_ComponentId *plugin_identity,
int operation_flags );
int slapi_add_internal_set_pb( Slapi_PBlock *pb, const char *dn,
LDAPMod **attrs, LDAPControl **controls,
Slapi_ComponentId *plugin_identity, int operation_flags );
void slapi_modify_internal_set_pb( Slapi_PBlock *pb, const char *dn,
LDAPMod **mods, LDAPControl **controls, const char *uniqueid,
Slapi_ComponentId *plugin_identity, int operation_flags );
void slapi_rename_internal_set_pb( Slapi_PBlock *pb, const char *olddn,
const char *newrdn, const char *newsuperior, int deloldrdn,
LDAPControl **controls, const char *uniqueid,
Slapi_ComponentId *plugin_identity, int operation_flags );
void slapi_delete_internal_set_pb( Slapi_PBlock *pb, const char *dn,
LDAPControl **controls, const char *uniqueid,
Slapi_ComponentId *plugin_identity, int operation_flags );
void slapi_seq_internal_set_pb( Slapi_PBlock *pb, char *ibase, int type,
char *attrname, char *val, char **attrs, int attrsonly,
LDAPControl **controls, Slapi_ComponentId *plugin_identity,
int operation_flags );
/* connection related routines */
int slapi_is_connection_ssl(Slapi_PBlock *pPB, int *isSSL);
int slapi_get_client_port(Slapi_PBlock *pPB, int *fromPort);
/* computed attributes */
typedef struct _computed_attr_context computed_attr_context;
typedef int (*slapi_compute_output_t)(computed_attr_context *c, Slapi_Attr *a, Slapi_Entry *e);
typedef int (*slapi_compute_callback_t)(computed_attr_context *c, char *type, Slapi_Entry *e, slapi_compute_output_t outputfn);
typedef int (*slapi_search_rewrite_callback_t)(Slapi_PBlock *pb);
int slapi_compute_add_evaluator(slapi_compute_callback_t function);
int slapi_compute_add_search_rewriter(slapi_search_rewrite_callback_t function);
int compute_rewrite_search_filter(Slapi_PBlock *pb);
int compute_evaluator(computed_attr_context *c, char *type, Slapi_Entry *e, slapi_compute_output_t outputfn);
int slapi_x_compute_get_pblock(computed_attr_context *c, Slapi_PBlock **pb);
/* backend routines */
void slapi_be_set_readonly( Slapi_Backend *be, int readonly );
int slapi_be_get_readonly( Slapi_Backend *be );
const char *slapi_x_be_get_updatedn( Slapi_Backend *be );
Slapi_Backend *slapi_be_select( const Slapi_DN *sdn );
/* ACL plugins; only SLAPI_PLUGIN_ACL_ALLOW_ACCESS supported now */
typedef int (*slapi_acl_callback_t)(Slapi_PBlock *pb,
Slapi_Entry *e,
const char *attr,
struct berval *berval,
int access,
void *state);
/* object extensions */
typedef void *(*slapi_extension_constructor_fnptr)(void *object, void *parent);
typedef void (*slapi_extension_destructor_fnptr)(void *extension,
void *object, void *parent);
int slapi_register_object_extension( const char *pluginname,
const char *objectname, slapi_extension_constructor_fnptr constructor,
slapi_extension_destructor_fnptr destructor, int *objecttype,
int *extensionhandle);
#define SLAPI_EXT_CONNECTION "Connection"
#define SLAPI_EXT_OPERATION "Operation"
#define SLAPI_EXT_ENTRY "Entry"
#define SLAPI_EXT_MTNODE "Mapping Tree Node"
void *slapi_get_object_extension(int objecttype, void *object,
int extensionhandle);
void slapi_set_object_extension(int objecttype, void *object,
int extensionhandle, void *extension);
int slapi_x_backend_get_flags( const Slapi_Backend *be, unsigned long *flags );
/* parameters currently supported */
/*
* Attribute flags returned by slapi_attr_get_flags()
*/
#define SLAPI_ATTR_FLAG_SINGLE 0x0001
#define SLAPI_ATTR_FLAG_OPATTR 0x0002
#define SLAPI_ATTR_FLAG_READONLY 0x0004
#define SLAPI_ATTR_FLAG_STD_ATTR SLAPI_ATTR_FLAG_READONLY
#define SLAPI_ATTR_FLAG_OBSOLETE 0x0040
#define SLAPI_ATTR_FLAG_COLLECTIVE 0x0080
#define SLAPI_ATTR_FLAG_NOUSERMOD 0x0100
/*
* Backend flags returned by slapi_x_backend_get_flags()
*/
#define SLAPI_BACKEND_FLAG_NOLASTMOD 0x0001U
#define SLAPI_BACKEND_FLAG_NO_SCHEMA_CHECK 0x0002U
#define SLAPI_BACKEND_FLAG_GLUE_INSTANCE 0x0010U /* a glue backend */
#define SLAPI_BACKEND_FLAG_GLUE_SUBORDINATE 0x0020U /* child of a glue hierarchy */
#define SLAPI_BACKEND_FLAG_GLUE_LINKED 0x0040U /* child is connected to parent */
#define SLAPI_BACKEND_FLAG_OVERLAY 0x0080U /* this db struct is an overlay */
#define SLAPI_BACKEND_FLAG_GLOBAL_OVERLAY 0x0100U /* this db struct is a global overlay */
#define SLAPI_BACKEND_FLAG_SHADOW 0x8000U /* a shadow */
#define SLAPI_BACKEND_FLAG_SYNC_SHADOW 0x1000U /* a sync shadow */
#define SLAPI_BACKEND_FLAG_SLURP_SHADOW 0x2000U /* a slurp shadow */
/*
* ACL levels
*/
#define SLAPI_ACL_COMPARE 0x01
#define SLAPI_ACL_SEARCH 0x02
#define SLAPI_ACL_READ 0x04
#define SLAPI_ACL_WRITE 0x08
#define SLAPI_ACL_DELETE 0x10
#define SLAPI_ACL_ADD 0x20
#define SLAPI_ACL_SELF 0x40
#define SLAPI_ACL_PROXY 0x80
#define SLAPI_ACL_ALL 0x7f
/* plugin types supported */
#define SLAPI_PLUGIN_DATABASE 1
#define SLAPI_PLUGIN_EXTENDEDOP 2
#define SLAPI_PLUGIN_PREOPERATION 3
#define SLAPI_PLUGIN_POSTOPERATION 4
#define SLAPI_PLUGIN_MATCHINGRULE 5
#define SLAPI_PLUGIN_SYNTAX 6
#define SLAPI_PLUGIN_AUDIT 7
/* misc params */
#define SLAPI_BACKEND 130
#define SLAPI_CONNECTION 131
#define SLAPI_OPERATION 132
#define SLAPI_REQUESTOR_ISROOT 133
#define SLAPI_BE_MONITORDN 134
#define SLAPI_BE_TYPE 135
#define SLAPI_BE_READONLY 136
#define SLAPI_BE_LASTMOD 137
#define SLAPI_CONN_ID 139
/* operation params */
#define SLAPI_OPINITIATED_TIME 140
#define SLAPI_REQUESTOR_DN 141
#define SLAPI_IS_REPLICATED_OPERATION 142
#define SLAPI_REQUESTOR_ISUPDATEDN SLAPI_IS_REPLICATED_OPERATION
/* connection structure params*/
#define SLAPI_CONN_DN 143
#define SLAPI_CONN_AUTHTYPE 144
#define SLAPI_CONN_CLIENTIP 145
#define SLAPI_CONN_SERVERIP 146
/* OpenLDAP extensions */
#define SLAPI_X_CONN_CLIENTPATH 1300
#define SLAPI_X_CONN_SERVERPATH 1301
#define SLAPI_X_CONN_IS_UDP 1302
#define SLAPI_X_CONN_SSF 1303
#define SLAPI_X_CONN_SASL_CONTEXT 1304
#define SLAPI_X_OPERATION_DELETE_GLUE_PARENT 1305
#define SLAPI_X_RELAX 1306
#define SLAPI_X_MANAGEDIT SLAPI_X_RELAX
#define SLAPI_X_OPERATION_NO_SCHEMA_CHECK 1307
#define SLAPI_X_ADD_STRUCTURAL_CLASS 1308
#define SLAPI_X_OPERATION_NO_SUBORDINATE_GLUE 1309
/* Authentication types */
#define SLAPD_AUTH_NONE "none"
#define SLAPD_AUTH_SIMPLE "simple"
#define SLAPD_AUTH_SSL "SSL"
#define SLAPD_AUTH_SASL "SASL "
/* plugin configuration parmams */
#define SLAPI_PLUGIN 3
#define SLAPI_PLUGIN_PRIVATE 4
#define SLAPI_PLUGIN_TYPE 5
#define SLAPI_PLUGIN_ARGV 6
#define SLAPI_PLUGIN_ARGC 7
#define SLAPI_PLUGIN_VERSION 8
#define SLAPI_PLUGIN_OPRETURN 9
#define SLAPI_PLUGIN_OBJECT 10
#define SLAPI_PLUGIN_DESTROY_FN 11
#define SLAPI_PLUGIN_DESCRIPTION 12
#define SLAPI_PLUGIN_IDENTITY 13
/* internal opreations params */
#define SLAPI_PLUGIN_INTOP_RESULT 15
#define SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES 16
#define SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS 17
/* transaction arguments */
#define SLAPI_PARENT_TXN 190
#define SLAPI_TXN 191
/* function pointer params for backends */
#define SLAPI_PLUGIN_DB_BIND_FN 200
#define SLAPI_PLUGIN_DB_UNBIND_FN 201
#define SLAPI_PLUGIN_DB_SEARCH_FN 202
#define SLAPI_PLUGIN_DB_COMPARE_FN 203
#define SLAPI_PLUGIN_DB_MODIFY_FN 204
#define SLAPI_PLUGIN_DB_MODRDN_FN 205
#define SLAPI_PLUGIN_DB_ADD_FN 206
#define SLAPI_PLUGIN_DB_DELETE_FN 207
#define SLAPI_PLUGIN_DB_ABANDON_FN 208
#define SLAPI_PLUGIN_DB_CONFIG_FN 209
#define SLAPI_PLUGIN_CLOSE_FN 210
#define SLAPI_PLUGIN_DB_FLUSH_FN 211
#define SLAPI_PLUGIN_START_FN 212
#define SLAPI_PLUGIN_DB_SEQ_FN 213
#define SLAPI_PLUGIN_DB_ENTRY_FN 214
#define SLAPI_PLUGIN_DB_REFERRAL_FN 215
#define SLAPI_PLUGIN_DB_RESULT_FN 216
#define SLAPI_PLUGIN_DB_LDIF2DB_FN 217
#define SLAPI_PLUGIN_DB_DB2LDIF_FN 218
#define SLAPI_PLUGIN_DB_BEGIN_FN 219
#define SLAPI_PLUGIN_DB_COMMIT_FN 220
#define SLAPI_PLUGIN_DB_ABORT_FN 221
#define SLAPI_PLUGIN_DB_ARCHIVE2DB_FN 222
#define SLAPI_PLUGIN_DB_DB2ARCHIVE_FN 223
#define SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN 224
#define SLAPI_PLUGIN_DB_FREE_RESULT_SET_FN 225
#define SLAPI_PLUGIN_DB_SIZE_FN 226
#define SLAPI_PLUGIN_DB_TEST_FN 227
/* functions pointers for LDAP V3 extended ops */
#define SLAPI_PLUGIN_EXT_OP_FN 300
#define SLAPI_PLUGIN_EXT_OP_OIDLIST 301
/* preoperation */
#define SLAPI_PLUGIN_PRE_BIND_FN 401
#define SLAPI_PLUGIN_PRE_UNBIND_FN 402
#define SLAPI_PLUGIN_PRE_SEARCH_FN 403
#define SLAPI_PLUGIN_PRE_COMPARE_FN 404
#define SLAPI_PLUGIN_PRE_MODIFY_FN 405
#define SLAPI_PLUGIN_PRE_MODRDN_FN 406
#define SLAPI_PLUGIN_PRE_ADD_FN 407
#define SLAPI_PLUGIN_PRE_DELETE_FN 408
#define SLAPI_PLUGIN_PRE_ABANDON_FN 409
#define SLAPI_PLUGIN_PRE_ENTRY_FN 410
#define SLAPI_PLUGIN_PRE_REFERRAL_FN 411
#define SLAPI_PLUGIN_PRE_RESULT_FN 412
/* internal preoperation */
#define SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN 420
#define SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN 421
#define SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN 422
#define SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN 423
/* backend preoperation */
#define SLAPI_PLUGIN_BE_PRE_ADD_FN 450
#define SLAPI_PLUGIN_BE_PRE_MODIFY_FN 451
#define SLAPI_PLUGIN_BE_PRE_MODRDN_FN 452
#define SLAPI_PLUGIN_BE_PRE_DELETE_FN 453
/* postoperation */
#define SLAPI_PLUGIN_POST_BIND_FN 501
#define SLAPI_PLUGIN_POST_UNBIND_FN 502
#define SLAPI_PLUGIN_POST_SEARCH_FN 503
#define SLAPI_PLUGIN_POST_COMPARE_FN 504
#define SLAPI_PLUGIN_POST_MODIFY_FN 505
#define SLAPI_PLUGIN_POST_MODRDN_FN 506
#define SLAPI_PLUGIN_POST_ADD_FN 507
#define SLAPI_PLUGIN_POST_DELETE_FN 508
#define SLAPI_PLUGIN_POST_ABANDON_FN 509
#define SLAPI_PLUGIN_POST_ENTRY_FN 510
#define SLAPI_PLUGIN_POST_REFERRAL_FN 511
#define SLAPI_PLUGIN_POST_RESULT_FN 512
/* internal postoperation */
#define SLAPI_PLUGIN_INTERNAL_POST_ADD_FN 520
#define SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN 521
#define SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN 522
#define SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN 523
/* backend postoperation */
#define SLAPI_PLUGIN_BE_POST_ADD_FN 550
#define SLAPI_PLUGIN_BE_POST_MODIFY_FN 551
#define SLAPI_PLUGIN_BE_POST_MODRDN_FN 552
#define SLAPI_PLUGIN_BE_POST_DELETE_FN 553
#define SLAPI_OPERATION_TYPE 590
#define SLAPI_OPERATION_MSGID 591
#define SLAPI_PLUGIN_MR_FILTER_CREATE_FN 600
#define SLAPI_PLUGIN_MR_INDEXER_CREATE_FN 601
#define SLAPI_PLUGIN_MR_FILTER_MATCH_FN 602
#define SLAPI_PLUGIN_MR_FILTER_INDEX_FN 603
#define SLAPI_PLUGIN_MR_FILTER_RESET_FN 604
#define SLAPI_PLUGIN_MR_INDEX_FN 605
#define SLAPI_PLUGIN_MR_OID 610
#define SLAPI_PLUGIN_MR_TYPE 611
#define SLAPI_PLUGIN_MR_VALUE 612
#define SLAPI_PLUGIN_MR_VALUES 613
#define SLAPI_PLUGIN_MR_KEYS 614
#define SLAPI_PLUGIN_MR_FILTER_REUSABLE 615
#define SLAPI_PLUGIN_MR_QUERY_OPERATOR 616
#define SLAPI_PLUGIN_MR_USAGE 617
#define SLAPI_MATCHINGRULE_NAME 1
#define SLAPI_MATCHINGRULE_OID 2
#define SLAPI_MATCHINGRULE_DESC 3
#define SLAPI_MATCHINGRULE_SYNTAX 4
#define SLAPI_MATCHINGRULE_OBSOLETE 5
#define SLAPI_OP_LESS 1
#define SLAPI_OP_LESS_OR_EQUAL 2
#define SLAPI_OP_EQUAL 3
#define SLAPI_OP_GREATER_OR_EQUAL 4
#define SLAPI_OP_GREATER 5
#define SLAPI_OP_SUBSTRING 6
#define SLAPI_PLUGIN_MR_USAGE_INDEX 0
#define SLAPI_PLUGIN_MR_USAGE_SORT 1
#define SLAPI_PLUGIN_SYNTAX_FILTER_AVA 700
#define SLAPI_PLUGIN_SYNTAX_FILTER_SUB 701
#define SLAPI_PLUGIN_SYNTAX_VALUES2KEYS 702
#define SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_AVA 703
#define SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_SUB 704
#define SLAPI_PLUGIN_SYNTAX_NAMES 705
#define SLAPI_PLUGIN_SYNTAX_OID 706
#define SLAPI_PLUGIN_SYNTAX_FLAGS 707
#define SLAPI_PLUGIN_SYNTAX_COMPARE 708
#define SLAPI_PLUGIN_SYNTAX_FLAG_ORKEYS 1
#define SLAPI_PLUGIN_SYNTAX_FLAG_ORDERING 2
#define SLAPI_PLUGIN_ACL_INIT 730
#define SLAPI_PLUGIN_ACL_SYNTAX_CHECK 731
#define SLAPI_PLUGIN_ACL_ALLOW_ACCESS 732
#define SLAPI_PLUGIN_ACL_MODS_ALLOWED 733
#define SLAPI_PLUGIN_ACL_MODS_UPDATE 734
#define SLAPI_OPERATION_AUTHTYPE 741
#define SLAPI_OPERATION_ID 742
#define SLAPI_CONN_CERT 743
#define SLAPI_CONN_AUTHMETHOD 746
#define SLAPI_IS_INTERNAL_OPERATION 748
#define SLAPI_RESULT_CODE 881
#define SLAPI_RESULT_TEXT 882
#define SLAPI_RESULT_MATCHED 883
/* managedsait control */
#define SLAPI_MANAGEDSAIT 1000
/* audit plugin defines */
#define SLAPI_PLUGIN_AUDIT_DATA 1100
#define SLAPI_PLUGIN_AUDIT_FN 1101
/* backend_group extension */
#define SLAPI_X_PLUGIN_PRE_GROUP_FN 1202
#define SLAPI_X_PLUGIN_POST_GROUP_FN 1203
#define SLAPI_X_GROUP_ENTRY 1250 /* group entry */
#define SLAPI_X_GROUP_ATTRIBUTE 1251 /* member attribute */
#define SLAPI_X_GROUP_OPERATION_DN 1252 /* asserted value */
#define SLAPI_X_GROUP_TARGET_ENTRY 1253 /* target entry */
/* internal preoperation extensions */
#define SLAPI_PLUGIN_INTERNAL_PRE_BIND_FN 1260
#define SLAPI_PLUGIN_INTERNAL_PRE_UNBIND_FN 1261
#define SLAPI_PLUGIN_INTERNAL_PRE_SEARCH_FN 1262
#define SLAPI_PLUGIN_INTERNAL_PRE_COMPARE_FN 1263
#define SLAPI_PLUGIN_INTERNAL_PRE_ABANDON_FN 1264
/* internal postoperation extensions */
#define SLAPI_PLUGIN_INTERNAL_POST_BIND_FN 1270
#define SLAPI_PLUGIN_INTERNAL_POST_UNBIND_FN 1271
#define SLAPI_PLUGIN_INTERNAL_POST_SEARCH_FN 1272
#define SLAPI_PLUGIN_INTERNAL_POST_COMPARE_FN 1273
#define SLAPI_PLUGIN_INTERNAL_POST_ABANDON_FN 1274
/* config stuff */
#define SLAPI_CONFIG_FILENAME 40
#define SLAPI_CONFIG_LINENO 41
#define SLAPI_CONFIG_ARGC 42
#define SLAPI_CONFIG_ARGV 43
/* operational params */
#define SLAPI_TARGET_ADDRESS 48
#define SLAPI_TARGET_UNIQUEID 49
#define SLAPI_TARGET_DN 50
/* server LDAPv3 controls */
#define SLAPI_REQCONTROLS 51
#define SLAPI_RESCONTROLS 55
#define SLAPI_ADD_RESCONTROL 56
#define SLAPI_CONTROLS_ARG 58
/* add params */
#define SLAPI_ADD_TARGET SLAPI_TARGET_DN
#define SLAPI_ADD_ENTRY 60
#define SLAPI_ADD_EXISTING_DN_ENTRY 61
#define SLAPI_ADD_PARENT_ENTRY 62
#define SLAPI_ADD_PARENT_UNIQUEID 63
#define SLAPI_ADD_EXISTING_UNIQUEID_ENTRY 64
/* bind params */
#define SLAPI_BIND_TARGET SLAPI_TARGET_DN
#define SLAPI_BIND_METHOD 70
#define SLAPI_BIND_CREDENTIALS 71
#define SLAPI_BIND_SASLMECHANISM 72
#define SLAPI_BIND_RET_SASLCREDS 73
/* compare params */
#define SLAPI_COMPARE_TARGET SLAPI_TARGET_DN
#define SLAPI_COMPARE_TYPE 80
#define SLAPI_COMPARE_VALUE 81
/* delete params */
#define SLAPI_DELETE_TARGET SLAPI_TARGET_DN
#define SLAPI_DELETE_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY
/* modify params */
#define SLAPI_MODIFY_TARGET SLAPI_TARGET_DN
#define SLAPI_MODIFY_MODS 90
#define SLAPI_MODIFY_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY
/* modrdn params */
#define SLAPI_MODRDN_TARGET SLAPI_TARGET_DN
#define SLAPI_MODRDN_NEWRDN 100
#define SLAPI_MODRDN_DELOLDRDN 101
#define SLAPI_MODRDN_NEWSUPERIOR 102 /* v3 only */
#define SLAPI_MODRDN_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY
#define SLAPI_MODRDN_PARENT_ENTRY 104
#define SLAPI_MODRDN_NEWPARENT_ENTRY 105
#define SLAPI_MODRDN_TARGET_ENTRY 106
#define SLAPI_MODRDN_NEWSUPERIOR_ADDRESS 107
/* search params */
#define SLAPI_SEARCH_TARGET SLAPI_TARGET_DN
#define SLAPI_SEARCH_SCOPE 110
#define SLAPI_SEARCH_DEREF 111
#define SLAPI_SEARCH_SIZELIMIT 112
#define SLAPI_SEARCH_TIMELIMIT 113
#define SLAPI_SEARCH_FILTER 114
#define SLAPI_SEARCH_STRFILTER 115
#define SLAPI_SEARCH_ATTRS 116
#define SLAPI_SEARCH_ATTRSONLY 117
/* abandon params */
#define SLAPI_ABANDON_MSGID 120
/* extended operation params */
#define SLAPI_EXT_OP_REQ_OID 160
#define SLAPI_EXT_OP_REQ_VALUE 161
/* extended operation return codes */
#define SLAPI_EXT_OP_RET_OID 162
#define SLAPI_EXT_OP_RET_VALUE 163
#define SLAPI_PLUGIN_EXTENDED_SENT_RESULT -1
#define SLAPI_FAIL_DISKFULL -2
#define SLAPI_FAIL_GENERAL -1
#define SLAPI_PLUGIN_EXTENDED_NOT_HANDLED -2
#define SLAPI_BIND_SUCCESS 0
#define SLAPI_BIND_FAIL 2
#define SLAPI_BIND_ANONYMOUS 3
/* Search result params */
#define SLAPI_SEARCH_RESULT_SET 193
#define SLAPI_SEARCH_RESULT_ENTRY 194
#define SLAPI_NENTRIES 195
#define SLAPI_SEARCH_REFERRALS 196
/* filter types */
#ifndef LDAP_FILTER_AND
#define LDAP_FILTER_AND 0xa0L
#endif
#ifndef LDAP_FILTER_OR
#define LDAP_FILTER_OR 0xa1L
#endif
#ifndef LDAP_FILTER_NOT
#define LDAP_FILTER_NOT 0xa2L
#endif
#ifndef LDAP_FILTER_EQUALITY
#define LDAP_FILTER_EQUALITY 0xa3L
#endif
#ifndef LDAP_FILTER_SUBSTRINGS
#define LDAP_FILTER_SUBSTRINGS 0xa4L
#endif
#ifndef LDAP_FILTER_GE
#define LDAP_FILTER_GE 0xa5L
#endif
#ifndef LDAP_FILTER_LE
#define LDAP_FILTER_LE 0xa6L
#endif
#ifndef LDAP_FILTER_PRESENT
#define LDAP_FILTER_PRESENT 0x87L
#endif
#ifndef LDAP_FILTER_APPROX
#define LDAP_FILTER_APPROX 0xa8L
#endif
#ifndef LDAP_FILTER_EXT_MATCH
#define LDAP_FILTER_EXT_MATCH 0xa9L
#endif
int slapi_log_error( int severity, char *subsystem, char *fmt, ... );
#define SLAPI_LOG_FATAL 0
#define SLAPI_LOG_TRACE 1
#define SLAPI_LOG_PACKETS 2
#define SLAPI_LOG_ARGS 3
#define SLAPI_LOG_CONNS 4
#define SLAPI_LOG_BER 5
#define SLAPI_LOG_FILTER 6
#define SLAPI_LOG_CONFIG 7
#define SLAPI_LOG_ACL 8
#define SLAPI_LOG_SHELL 9
#define SLAPI_LOG_PARSE 10
#define SLAPI_LOG_HOUSE 11
#define SLAPI_LOG_REPL 12
#define SLAPI_LOG_CACHE 13
#define SLAPI_LOG_PLUGIN 14
#define SLAPI_LOG_TIMING 15
#define SLAPI_PLUGIN_DESCRIPTION 12
typedef struct slapi_plugindesc {
char *spd_id;
char *spd_vendor;
char *spd_version;
char *spd_description;
} Slapi_PluginDesc;
#define SLAPI_PLUGIN_VERSION_01 "01"
#define SLAPI_PLUGIN_VERSION_02 "02"
#define SLAPI_PLUGIN_VERSION_03 "03"
#define SLAPI_PLUGIN_CURRENT_VERSION SLAPI_PLUGIN_VERSION_03
#endif /* _SLAPI_PLUGIN_H */
golang-openldap-0.2/_docs/ldap-sample.c 0000664 0000000 0000000 00000001024 11766376717 0020076 0 ustar 00root root 0000000 0000000
// search / read example
for ( e = ldap_first_entry( ld, res ); e != NULL; e = ldap_next_entry( ld, e ) )
{
struct berval **v = ldap_get_values_len( ld, e, attr );
if ( v != NULL ) {
int n = ldap_count_values_len( v );
int j;
values = realloc( values, ( nvalues + n + 1 )*sizeof( char * ) );
for ( j = 0; j < n; j++ ) {
values[ nvalues + j ] = strdup( v[ j ]->bv_val );
}
values[ nvalues + j ] = NULL;
nvalues += n;
ldap_value_free_len( v );
}
}
ldap_msgfree( res );
golang-openldap-0.2/_docs/ldap_linux.go 0000664 0000000 0000000 00000211214 11766376717 0020225 0 ustar 00root root 0000000 0000000 // def2go -w=true -d=true -s=linux -p=openldap include/ldap.h
// MACHINE GENERATED; DO NOT EDIT
// ===
package openldap
// $OpenLDAP$
// This work is part of OpenLDAP Software .
// *
// Copyright 1998-2012 The OpenLDAP Foundation.
// All rights reserved.
// *
// Redistribution and use in source and binary forms, with or without
// modification, are permitted only as authorized by the OpenLDAP
// Public License.
// *
// A copy of this license is available in file LICENSE in the
// top-level directory of the distribution or, alternatively, at
// .// Portions Copyright (c) 1990 Regents of the University of Michigan.
// All rights reserved.
// *
// Redistribution and use in source and binary forms are permitted
// provided that this notice is preserved and that due credit is given
// to the University of Michigan at Ann Arbor. The name of the University
// may not be used to endorse or promote products derived from this
// software without specific prior written permission. This software
// is provided ``as is'' without express or implied warranty.
//!!! #ifndef _LDAP_H
//!!! #define _LDAP_H
// pull in lber
//!!! #include
// include version and API feature defines
//!!! #include
//!!! LDAP_BEGIN_DECL
const (
LDAP_VERSION1 = 1
LDAP_VERSION2 = 2
LDAP_VERSION3 = 3
)
const (
LDAP_VERSION_MIN = LDAP_VERSION2
LDAP_VERSION = LDAP_VERSION2
LDAP_VERSION_MAX = LDAP_VERSION3
)
//
// We use 3000+n here because it is above 1823 (for RFC 1823),
// above 2000+rev of IETF LDAPEXT draft (now quite dated),
// yet below allocations for new RFCs (just in case there is
// someday an RFC produced).
const (
LDAP_API_VERSION = 3001
LDAP_VENDOR_NAME = "OpenLDAP"
)
// OpenLDAP API Features
const LDAP_API_FEATURE_X_OPENLDAP = LDAP_VENDOR_VERSION
//!!! #if defined( LDAP_API_FEATURE_X_OPENLDAP_REENTRANT ) || \
//!!! ( defined( LDAP_THREAD_SAFE ) && \
//!!! defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE ) )
// -lldap may or may not be thread safe
// -lldap_r, if available, is always thread safe
const (
LDAP_API_FEATURE_THREAD_SAFE = 1
LDAP_API_FEATURE_SESSION_THREAD_SAFE = 1
LDAP_API_FEATURE_OPERATION_THREAD_SAFE = 1
//!!! #endif
//!!! #if defined( LDAP_THREAD_SAFE ) && \
//!!! defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE )
// #define LDAP_API_FEATURE_SESSION_SAFE 1
// #define LDAP_API_OPERATION_SESSION_SAFE 1
//!!! #endif
)
const (
LDAP_PORT = 389 // ldap:/// default LDAP port
LDAPS_PORT = 636 // ldaps:/// default LDAP over TLS port
)
const (
LDAP_ROOT_DSE = ""
LDAP_NO_ATTRS = "1.1"
LDAP_ALL_USER_ATTRIBUTES = "*"
LDAP_ALL_OPERATIONAL_ATTRIBUTES = "+" // RFC 3673
)
// RFC 4511: maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) --
//!!! const LDAP_MAXINT = (2147483647)
//
// LDAP_OPTions
// 0x0000 - 0x0fff reserved for api options
// 0x1000 - 0x3fff reserved for api extended options
// 0x4000 - 0x7fff reserved for private and experimental options
const (
LDAP_OPT_API_INFO = 0x0000
LDAP_OPT_DESC = 0x0001 // historic
LDAP_OPT_DEREF = 0x0002
LDAP_OPT_SIZELIMIT = 0x0003
LDAP_OPT_TIMELIMIT = 0x0004
// 0x05 - 0x07 not defined
LDAP_OPT_REFERRALS = 0x0008
LDAP_OPT_RESTART = 0x0009
// 0x0a - 0x10 not defined
LDAP_OPT_PROTOCOL_VERSION = 0x0011
LDAP_OPT_SERVER_CONTROLS = 0x0012
LDAP_OPT_CLIENT_CONTROLS = 0x0013
// 0x14 not defined
LDAP_OPT_API_FEATURE_INFO = 0x0015
// 0x16 - 0x2f not defined
LDAP_OPT_HOST_NAME = 0x0030
LDAP_OPT_RESULT_CODE = 0x0031
LDAP_OPT_ERROR_NUMBER = LDAP_OPT_RESULT_CODE
LDAP_OPT_DIAGNOSTIC_MESSAGE = 0x0032
LDAP_OPT_ERROR_STRING = LDAP_OPT_DIAGNOSTIC_MESSAGE
LDAP_OPT_MATCHED_DN = 0x0033
// 0x0034 - 0x3fff not defined
// 0x0091 used by Microsoft for LDAP_OPT_AUTO_RECONNECT
LDAP_OPT_SSPI_FLAGS = 0x0092
// 0x0093 used by Microsoft for LDAP_OPT_SSL_INFO
// 0x0094 used by Microsoft for LDAP_OPT_REF_DEREF_CONN_PER_MSG
LDAP_OPT_SIGN = 0x0095
LDAP_OPT_ENCRYPT = 0x0096
LDAP_OPT_SASL_METHOD = 0x0097
// 0x0098 used by Microsoft for LDAP_OPT_AREC_EXCLUSIVE
LDAP_OPT_SECURITY_CONTEXT = 0x0099
// 0x009A used by Microsoft for LDAP_OPT_ROOTDSE_CACHE
// 0x009B - 0x3fff not defined
)
// API Extensions
const LDAP_OPT_API_EXTENSION_BASE = 0x4000 // API extensions
// private and experimental options
// OpenLDAP specific options
const (
LDAP_OPT_DEBUG_LEVEL = 0x5001 // debug level
LDAP_OPT_TIMEOUT = 0x5002 // default timeout
LDAP_OPT_REFHOPLIMIT = 0x5003 // ref hop limit
LDAP_OPT_NETWORK_TIMEOUT = 0x5005 // socket level timeout
LDAP_OPT_URI = 0x5006
LDAP_OPT_REFERRAL_URLS = 0x5007 // Referral URLs
LDAP_OPT_SOCKBUF = 0x5008 // sockbuf
LDAP_OPT_DEFBASE = 0x5009 // searchbase
LDAP_OPT_CONNECT_ASYNC = 0x5010 // create connections asynchronously
LDAP_OPT_CONNECT_CB = 0x5011 // connection callbacks
LDAP_OPT_SESSION_REFCNT = 0x5012 // session reference count
)
// OpenLDAP TLS options
const (
LDAP_OPT_X_TLS = 0x6000
LDAP_OPT_X_TLS_CTX = 0x6001 // OpenSSL CTX*
LDAP_OPT_X_TLS_CACERTFILE = 0x6002
LDAP_OPT_X_TLS_CACERTDIR = 0x6003
LDAP_OPT_X_TLS_CERTFILE = 0x6004
LDAP_OPT_X_TLS_KEYFILE = 0x6005
LDAP_OPT_X_TLS_REQUIRE_CERT = 0x6006
LDAP_OPT_X_TLS_PROTOCOL_MIN = 0x6007
LDAP_OPT_X_TLS_CIPHER_SUITE = 0x6008
LDAP_OPT_X_TLS_RANDOM_FILE = 0x6009
LDAP_OPT_X_TLS_SSL_CTX = 0x600a // OpenSSL SSL*
LDAP_OPT_X_TLS_CRLCHECK = 0x600b
LDAP_OPT_X_TLS_CONNECT_CB = 0x600c
LDAP_OPT_X_TLS_CONNECT_ARG = 0x600d
LDAP_OPT_X_TLS_DHFILE = 0x600e
LDAP_OPT_X_TLS_NEWCTX = 0x600f
LDAP_OPT_X_TLS_CRLFILE = 0x6010 // GNUtls only
LDAP_OPT_X_TLS_PACKAGE = 0x6011
)
const (
LDAP_OPT_X_TLS_NEVER = 0
LDAP_OPT_X_TLS_HARD = 1
LDAP_OPT_X_TLS_DEMAND = 2
LDAP_OPT_X_TLS_ALLOW = 3
LDAP_OPT_X_TLS_TRY = 4
)
const (
LDAP_OPT_X_TLS_CRL_NONE = 0
LDAP_OPT_X_TLS_CRL_PEER = 1
LDAP_OPT_X_TLS_CRL_ALL = 2
)
// for LDAP_OPT_X_TLS_PROTOCOL_MIN
//!!! const (
LDAP_OPT_X_TLS_PROTOCOL(maj,min) = (((maj) << 8) + (min))
//!!! LDAP_OPT_X_TLS_PROTOCOL_SSL2 = (2 << 8)
//!!! LDAP_OPT_X_TLS_PROTOCOL_SSL3 = (3 << 8)
//!!! LDAP_OPT_X_TLS_PROTOCOL_TLS1_0 = ((3 << 8) + 1)
//!!! LDAP_OPT_X_TLS_PROTOCOL_TLS1_1 = ((3 << 8) + 2)
//!!! LDAP_OPT_X_TLS_PROTOCOL_TLS1_2 = ((3 << 8) + 3)
)
// OpenLDAP SASL options
const (
LDAP_OPT_X_SASL_MECH = 0x6100
LDAP_OPT_X_SASL_REALM = 0x6101
LDAP_OPT_X_SASL_AUTHCID = 0x6102
LDAP_OPT_X_SASL_AUTHZID = 0x6103
LDAP_OPT_X_SASL_SSF = 0x6104 // read-only
LDAP_OPT_X_SASL_SSF_EXTERNAL = 0x6105 // write-only
LDAP_OPT_X_SASL_SECPROPS = 0x6106 // write-only
LDAP_OPT_X_SASL_SSF_MIN = 0x6107
LDAP_OPT_X_SASL_SSF_MAX = 0x6108
LDAP_OPT_X_SASL_MAXBUFSIZE = 0x6109
LDAP_OPT_X_SASL_MECHLIST = 0x610a // read-only
LDAP_OPT_X_SASL_NOCANON = 0x610b
LDAP_OPT_X_SASL_USERNAME = 0x610c // read-only
LDAP_OPT_X_SASL_GSS_CREDS = 0x610d
)
// OpenLDAP GSSAPI options
const (
LDAP_OPT_X_GSSAPI_DO_NOT_FREE_CONTEXT = 0x6200
LDAP_OPT_X_GSSAPI_ALLOW_REMOTE_PRINCIPAL = 0x6201
)
//
// OpenLDAP per connection tcp-keepalive settings
// (Linux only, ignored where unsupported)const (
LDAP_OPT_X_KEEPALIVE_IDLE = 0x6300
LDAP_OPT_X_KEEPALIVE_PROBES = 0x6301
LDAP_OPT_X_KEEPALIVE_INTERVAL = 0x6302
)
// Private API Extensions -- reserved for application use
const LDAP_OPT_PRIVATE_EXTENSION_BASE = 0x7000 // Private API inclusive
//
// ldap_get_option() and ldap_set_option() return values.
// As later versions may return other values indicating
// failure, current applications should only compare returned
// value against LDAP_OPT_SUCCESS.const (
LDAP_OPT_SUCCESS = 0
//!!! LDAP_OPT_ERROR = (-1)
)
// option on/off values
//!!! const (
LDAP_OPT_ON = ((void *) &ber_pvt_opt_on)
//!!! LDAP_OPT_OFF = ((void *) 0)
)
//!!! typedef struct ldapapiinfo {
//!!! int ldapai_info_version; // version of LDAPAPIInfo
//!!! const LDAP_API_INFO_VERSION = (1)
//!!! int ldapai_api_version; // revision of API supported
//!!! int ldapai_protocol_version; // highest LDAP version supported
//!!! char **ldapai_extensions; // names of API extensions
//!!! char *ldapai_vendor_name; // name of supplier
//!!! int ldapai_vendor_version; // supplier-specific version * 100
//!!! } LDAPAPIInfo;
//!!! typedef struct ldap_apifeature_info {
//!!! int ldapaif_info_version; // version of LDAPAPIFeatureInfo
//!!! const LDAP_FEATURE_INFO_VERSION = (1) // apifeature_info struct version
//!!! char* ldapaif_name; // LDAP_API_FEATURE_* (less prefix)
//!!! int ldapaif_version; // value of LDAP_API_FEATURE_...
//!!! } LDAPAPIFeatureInfo;
//
// LDAP Control structure//!!! typedef struct ldapcontrol {
//!!! char * ldctl_oid; // numericoid of control
//!!! struct berval ldctl_value; // encoded value of control
//!!! char ldctl_iscritical; // criticality
//!!! } LDAPControl;
// LDAP Controls
// standard track controls
const (
LDAP_CONTROL_MANAGEDSAIT = "2.16.840.1.113730.3.4.2" // RFC 3296
LDAP_CONTROL_PROXY_AUTHZ = "2.16.840.1.113730.3.4.18" // RFC 4370
LDAP_CONTROL_SUBENTRIES = "1.3.6.1.4.1.4203.1.10.1" // RFC 3672
)
const LDAP_CONTROL_VALUESRETURNFILTER = "1.2.826.0.1.3344810.2.3"// RFC 3876
const (
LDAP_CONTROL_ASSERT = "1.3.6.1.1.12" // RFC 4528
LDAP_CONTROL_PRE_READ = "1.3.6.1.1.13.1" // RFC 4527
LDAP_CONTROL_POST_READ = "1.3.6.1.1.13.2" // RFC 4527
)
const (
LDAP_CONTROL_SORTREQUEST = "1.2.840.113556.1.4.473" // RFC 2891
LDAP_CONTROL_SORTRESPONSE = "1.2.840.113556.1.4.474" // RFC 2891
)
// non-standard track controls
const LDAP_CONTROL_PAGEDRESULTS = "1.2.840.113556.1.4.319" // RFC 2696
// LDAP Content Synchronization Operation -- RFC 4533
const (
LDAP_SYNC_OID = "1.3.6.1.4.1.4203.1.9.1"
LDAP_CONTROL_SYNC = LDAP_SYNC_OID ".1"
LDAP_CONTROL_SYNC_STATE = LDAP_SYNC_OID ".2"
LDAP_CONTROL_SYNC_DONE = LDAP_SYNC_OID ".3"
LDAP_SYNC_INFO = LDAP_SYNC_OID ".4"
)
const (
LDAP_SYNC_NONE = 0x00
LDAP_SYNC_REFRESH_ONLY = 0x01
LDAP_SYNC_RESERVED = 0x02
LDAP_SYNC_REFRESH_AND_PERSIST = 0x03
)
const (
LDAP_SYNC_REFRESH_PRESENTS = 0
LDAP_SYNC_REFRESH_DELETES = 1
)
//!!! const (
LDAP_TAG_SYNC_NEW_COOKIE = ((ber_tag_t) 0x80U)
//!!! LDAP_TAG_SYNC_REFRESH_DELETE = ((ber_tag_t) 0xa1U)
//!!! LDAP_TAG_SYNC_REFRESH_PRESENT = ((ber_tag_t) 0xa2U)
//!!! LDAP_TAG_SYNC_ID_SET = ((ber_tag_t) 0xa3U)
)
//!!! const (
LDAP_TAG_SYNC_COOKIE = ((ber_tag_t) 0x04U)
//!!! LDAP_TAG_REFRESHDELETES = ((ber_tag_t) 0x01U)
//!!! LDAP_TAG_REFRESHDONE = ((ber_tag_t) 0x01U)
//!!! LDAP_TAG_RELOAD_HINT = ((ber_tag_t) 0x01U)
)
const (
LDAP_SYNC_PRESENT = 0
LDAP_SYNC_ADD = 1
LDAP_SYNC_MODIFY = 2
LDAP_SYNC_DELETE = 3
LDAP_SYNC_NEW_COOKIE = 4
)
//!!! /* Password policy Controls */// work in progress
// ITS#3458: released; disabled by default
const (
LDAP_CONTROL_PASSWORDPOLICYREQUEST = "1.3.6.1.4.1.42.2.27.8.5.1"
LDAP_CONTROL_PASSWORDPOLICYRESPONSE = "1.3.6.1.4.1.42.2.27.8.5.1"
)
// various works in progress
const (
LDAP_CONTROL_NOOP = "1.3.6.1.4.1.4203.666.5.2"
LDAP_CONTROL_NO_SUBORDINATES = "1.3.6.1.4.1.4203.666.5.11"
LDAP_CONTROL_RELAX = "1.3.6.1.4.1.4203.666.5.12"
LDAP_CONTROL_MANAGEDIT = LDAP_CONTROL_RELAX
LDAP_CONTROL_SLURP = "1.3.6.1.4.1.4203.666.5.13"
LDAP_CONTROL_VALSORT = "1.3.6.1.4.1.4203.666.5.14"
LDAP_CONTROL_DONTUSECOPY = "1.3.6.1.4.1.4203.666.5.15"
LDAP_CONTROL_X_DEREF = "1.3.6.1.4.1.4203.666.5.16"
LDAP_CONTROL_X_WHATFAILED = "1.3.6.1.4.1.4203.666.5.17"
)
//!!! /* LDAP Chaining Behavior Control */// work in progress
// ;// * see also LDAP_NO_REFERRALS_FOUND, LDAP_CANNOT_CHAIN
const LDAP_CONTROL_X_CHAINING_BEHAVIOR = "1.3.6.1.4.1.4203.666.11.3"
const (
LDAP_CHAINING_PREFERRED = 0
LDAP_CHAINING_REQUIRED = 1
LDAP_REFERRALS_PREFERRED = 2
LDAP_REFERRALS_REQUIRED = 3
)
// MS Active Directory controls (for compatibility)
const (
LDAP_CONTROL_X_INCREMENTAL_VALUES = "1.2.840.113556.1.4.802"
LDAP_CONTROL_X_DOMAIN_SCOPE = "1.2.840.113556.1.4.1339"
LDAP_CONTROL_X_PERMISSIVE_MODIFY = "1.2.840.113556.1.4.1413"
LDAP_CONTROL_X_SEARCH_OPTIONS = "1.2.840.113556.1.4.1340"
LDAP_SEARCH_FLAG_DOMAIN_SCOPE = 1 // do not generate referrals
LDAP_SEARCH_FLAG_PHANTOM_ROOT = 2 // search all subordinate NCs
LDAP_CONTROL_X_TREE_DELETE = "1.2.840.113556.1.4.805"
)
// MS Active Directory controls - not implemented in slapd(8)
const LDAP_CONTROL_X_EXTENDED_DN = "1.2.840.113556.1.4.529"
//
const (
LDAP_CONTROL_X_SESSION_TRACKING = "1.3.6.1.4.1.21008.108.63.1"
LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_SESSION_ID = \
//!!! LDAP_CONTROL_X_SESSION_TRACKING ".1"
LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_MULTI_SESSION_ID = \
//!!! LDAP_CONTROL_X_SESSION_TRACKING ".2"
LDAP_CONTROL_X_SESSION_TRACKING_USERNAME = \
//!!! LDAP_CONTROL_X_SESSION_TRACKING ".3"
// various expired works
)
//!!! /* LDAP Duplicated Entry Control Extension */// not implemented in slapd(8)
const (
LDAP_CONTROL_DUPENT_REQUEST = "2.16.840.1.113719.1.27.101.1"
LDAP_CONTROL_DUPENT_RESPONSE = "2.16.840.1.113719.1.27.101.2"
LDAP_CONTROL_DUPENT_ENTRY = "2.16.840.1.113719.1.27.101.3"
LDAP_CONTROL_DUPENT = LDAP_CONTROL_DUPENT_REQUEST
)
//!!! /* LDAP Persistent Search Control */// not implemented in slapd(8)
const (
LDAP_CONTROL_PERSIST_REQUEST = "2.16.840.1.113730.3.4.3"
LDAP_CONTROL_PERSIST_ENTRY_CHANGE_NOTICE = "2.16.840.1.113730.3.4.7"
LDAP_CONTROL_PERSIST_ENTRY_CHANGE_ADD = 0x1
LDAP_CONTROL_PERSIST_ENTRY_CHANGE_DELETE = 0x2
LDAP_CONTROL_PERSIST_ENTRY_CHANGE_MODIFY = 0x4
LDAP_CONTROL_PERSIST_ENTRY_CHANGE_RENAME = 0x8
)
// LDAP VLV
const (
LDAP_CONTROL_VLVREQUEST = "2.16.840.1.113730.3.4.9"
LDAP_CONTROL_VLVRESPONSE = "2.16.840.1.113730.3.4.10"
)
// LDAP Unsolicited Notifications
const (
LDAP_NOTICE_OF_DISCONNECTION = "1.3.6.1.4.1.1466.20036" // RFC 4511
LDAP_NOTICE_DISCONNECT = LDAP_NOTICE_OF_DISCONNECTION
)
// LDAP Extended Operations
const LDAP_EXOP_START_TLS = "1.3.6.1.4.1.1466.20037" // RFC 4511
const (
LDAP_EXOP_MODIFY_PASSWD = "1.3.6.1.4.1.4203.1.11.1" // RFC 3062
//!!! LDAP_TAG_EXOP_MODIFY_PASSWD_ID = ((ber_tag_t) 0x80U)
//!!! LDAP_TAG_EXOP_MODIFY_PASSWD_OLD = ((ber_tag_t) 0x81U)
//!!! LDAP_TAG_EXOP_MODIFY_PASSWD_NEW = ((ber_tag_t) 0x82U)
//!!! LDAP_TAG_EXOP_MODIFY_PASSWD_GEN = ((ber_tag_t) 0x80U)
)
const (
LDAP_EXOP_CANCEL = "1.3.6.1.1.8" // RFC 3909
LDAP_EXOP_X_CANCEL = LDAP_EXOP_CANCEL
)
const (
LDAP_EXOP_REFRESH = "1.3.6.1.4.1.1466.101.119.1" // RFC 2589
//!!! LDAP_TAG_EXOP_REFRESH_REQ_DN = ((ber_tag_t) 0x80U)
//!!! LDAP_TAG_EXOP_REFRESH_REQ_TTL = ((ber_tag_t) 0x81U)
//!!! LDAP_TAG_EXOP_REFRESH_RES_TTL = ((ber_tag_t) 0x81U)
)
const (
LDAP_EXOP_WHO_AM_I = "1.3.6.1.4.1.4203.1.11.3" // RFC 4532
LDAP_EXOP_X_WHO_AM_I = LDAP_EXOP_WHO_AM_I
)
// various works in progress
const (
LDAP_EXOP_TURN = "1.3.6.1.1.19" // RFC 4531
LDAP_EXOP_X_TURN = LDAP_EXOP_TURN
)
// LDAP Distributed Procedures
// a work in progress
const (
LDAP_X_DISTPROC_BASE = "1.3.6.1.4.1.4203.666.11.6"
LDAP_EXOP_X_CHAINEDREQUEST = LDAP_X_DISTPROC_BASE ".1"
LDAP_FEATURE_X_CANCHAINOPS = LDAP_X_DISTPROC_BASE ".2"
LDAP_CONTROL_X_RETURNCONTREF = LDAP_X_DISTPROC_BASE ".3"
LDAP_URLEXT_X_LOCALREFOID = LDAP_X_DISTPROC_BASE ".4"
LDAP_URLEXT_X_REFTYPEOID = LDAP_X_DISTPROC_BASE ".5"
LDAP_URLEXT_X_SEARCHEDSUBTREEOID = \
//!!! LDAP_X_DISTPROC_BASE ".6"
LDAP_URLEXT_X_FAILEDNAMEOID = LDAP_X_DISTPROC_BASE ".7"
LDAP_URLEXT_X_LOCALREF = "x-localReference"
LDAP_URLEXT_X_REFTYPE = "x-referenceType"
LDAP_URLEXT_X_SEARCHEDSUBTREE = "x-searchedSubtree"
LDAP_URLEXT_X_FAILEDNAME = "x-failedName"
)
//!!! #ifdef LDAP_DEVEL
const (
LDAP_X_TXN = "1.3.6.1.4.1.4203.666.11.7" // tmp
LDAP_EXOP_X_TXN_START = LDAP_X_TXN ".1"
LDAP_CONTROL_X_TXN_SPEC = LDAP_X_TXN ".2"
LDAP_EXOP_X_TXN_END = LDAP_X_TXN ".3"
LDAP_EXOP_X_TXN_ABORTED_NOTICE = LDAP_X_TXN ".4"
//!!! #endif
)
// LDAP Features
const (
LDAP_FEATURE_ALL_OP_ATTRS = "1.3.6.1.4.1.4203.1.5.1" // RFC 3673
LDAP_FEATURE_OBJECTCLASS_ATTRS = \
//!!! "1.3.6.1.4.1.4203.1.5.2" // @objectClass - new number to be assigned
LDAP_FEATURE_ABSOLUTE_FILTERS = "1.3.6.1.4.1.4203.1.5.3" // (&) (|)
LDAP_FEATURE_LANGUAGE_TAG_OPTIONS = "1.3.6.1.4.1.4203.1.5.4"
LDAP_FEATURE_LANGUAGE_RANGE_OPTIONS = "1.3.6.1.4.1.4203.1.5.5"
LDAP_FEATURE_MODIFY_INCREMENT = "1.3.6.1.1.14"
)
// LDAP Experimental (works in progress) Features
const LDAP_FEATURE_SUBORDINATE_SCOPE = \
//!!! "1.3.6.1.4.1.4203.666.8.1" // "children"
const LDAP_FEATURE_CHILDREN_SCOPE = LDAP_FEATURE_SUBORDINATE_SCOPE
//
// specific LDAP instantiations of BER types we know about
// Overview of LBER tag construction
// *
// Bits
// ______
// 8 7 | CLASS
// 0 0 = UNIVERSAL
// 0 1 = APPLICATION
// 1 0 = CONTEXT-SPECIFIC
// 1 1 = PRIVATE
// _____
// | 6 | DATA-TYPE
// 0 = PRIMITIVE
// 1 = CONSTRUCTED
// ___________
// | 5 ... 1 | TAG-NUMBER
// general stuff
//!!! const (
LDAP_TAG_MESSAGE = ((ber_tag_t) 0x30U) // constructed + 16
//!!! LDAP_TAG_MSGID = ((ber_tag_t) 0x02U) // integer
)
//!!! const (
LDAP_TAG_LDAPDN = ((ber_tag_t) 0x04U) // octet string
//!!! LDAP_TAG_LDAPCRED = ((ber_tag_t) 0x04U) // octet string
)
//!!! const (
LDAP_TAG_CONTROLS = ((ber_tag_t) 0xa0U) // context specific + constructed + 0
//!!! LDAP_TAG_REFERRAL = ((ber_tag_t) 0xa3U) // context specific + constructed + 3
)
//!!! const LDAP_TAG_NEWSUPERIOR = ((ber_tag_t) 0x80U) // context-specific + primitive + 0
//!!! const (
LDAP_TAG_EXOP_REQ_OID = ((ber_tag_t) 0x80U) // context specific + primitive
//!!! LDAP_TAG_EXOP_REQ_VALUE = ((ber_tag_t) 0x81U) // context specific + primitive
//!!! LDAP_TAG_EXOP_RES_OID = ((ber_tag_t) 0x8aU) // context specific + primitive
//!!! LDAP_TAG_EXOP_RES_VALUE = ((ber_tag_t) 0x8bU) // context specific + primitive
)
//!!! const (
LDAP_TAG_IM_RES_OID = ((ber_tag_t) 0x80U) // context specific + primitive
//!!! LDAP_TAG_IM_RES_VALUE = ((ber_tag_t) 0x81U) // context specific + primitive
)
//!!! const LDAP_TAG_SASL_RES_CREDS = ((ber_tag_t) 0x87U) // context specific + primitive
// LDAP Request Messages
//!!! const (
LDAP_REQ_BIND = ((ber_tag_t) 0x60U) // application + constructed
//!!! LDAP_REQ_UNBIND = ((ber_tag_t) 0x42U) // application + primitive
//!!! LDAP_REQ_SEARCH = ((ber_tag_t) 0x63U) // application + constructed
//!!! LDAP_REQ_MODIFY = ((ber_tag_t) 0x66U) // application + constructed
//!!! LDAP_REQ_ADD = ((ber_tag_t) 0x68U) // application + constructed
//!!! LDAP_REQ_DELETE = ((ber_tag_t) 0x4aU) // application + primitive
//!!! LDAP_REQ_MODDN = ((ber_tag_t) 0x6cU) // application + constructed
LDAP_REQ_MODRDN = LDAP_REQ_MODDN
LDAP_REQ_RENAME = LDAP_REQ_MODDN
//!!! LDAP_REQ_COMPARE = ((ber_tag_t) 0x6eU) // application + constructed
//!!! LDAP_REQ_ABANDON = ((ber_tag_t) 0x50U) // application + primitive
//!!! LDAP_REQ_EXTENDED = ((ber_tag_t) 0x77U) // application + constructed
)
// LDAP Response Messages
//!!! const (
LDAP_RES_BIND = ((ber_tag_t) 0x61U) // application + constructed
//!!! LDAP_RES_SEARCH_ENTRY = ((ber_tag_t) 0x64U) // application + constructed
//!!! LDAP_RES_SEARCH_REFERENCE = ((ber_tag_t) 0x73U) // V3: application + constructed
//!!! LDAP_RES_SEARCH_RESULT = ((ber_tag_t) 0x65U) // application + constructed
//!!! LDAP_RES_MODIFY = ((ber_tag_t) 0x67U) // application + constructed
//!!! LDAP_RES_ADD = ((ber_tag_t) 0x69U) // application + constructed
//!!! LDAP_RES_DELETE = ((ber_tag_t) 0x6bU) // application + constructed
//!!! LDAP_RES_MODDN = ((ber_tag_t) 0x6dU) // application + constructed
LDAP_RES_MODRDN = LDAP_RES_MODDN // application + constructed
LDAP_RES_RENAME = LDAP_RES_MODDN // application + constructed
//!!! LDAP_RES_COMPARE = ((ber_tag_t) 0x6fU) // application + constructed
//!!! LDAP_RES_EXTENDED = ((ber_tag_t) 0x78U) // V3: application + constructed
//!!! LDAP_RES_INTERMEDIATE = ((ber_tag_t) 0x79U) // V3+: application + constructed
)
//!!! const (
LDAP_RES_ANY = (-1)
//!!! LDAP_RES_UNSOLICITED = (0)
)
// sasl methods
//!!! const (
LDAP_SASL_SIMPLE = ((char*)0)
//!!! LDAP_SASL_NULL = ("")
)
// authentication methods available
//!!! const (
LDAP_AUTH_NONE = ((ber_tag_t) 0x00U) // no authentication
//!!! LDAP_AUTH_SIMPLE = ((ber_tag_t) 0x80U) // context specific + primitive
//!!! LDAP_AUTH_SASL = ((ber_tag_t) 0xa3U) // context specific + constructed
//!!! LDAP_AUTH_KRBV4 = ((ber_tag_t) 0xffU) // means do both of the following
//!!! LDAP_AUTH_KRBV41 = ((ber_tag_t) 0x81U) // context specific + primitive
//!!! LDAP_AUTH_KRBV42 = ((ber_tag_t) 0x82U) // context specific + primitive
)
// used by the Windows API but not used on the wire
//!!! const LDAP_AUTH_NEGOTIATE = ((ber_tag_t) 0x04FFU)
// filter types
//!!! const (
LDAP_FILTER_AND = ((ber_tag_t) 0xa0U) // context specific + constructed
//!!! LDAP_FILTER_OR = ((ber_tag_t) 0xa1U) // context specific + constructed
//!!! LDAP_FILTER_NOT = ((ber_tag_t) 0xa2U) // context specific + constructed
//!!! LDAP_FILTER_EQUALITY = ((ber_tag_t) 0xa3U) // context specific + constructed
//!!! LDAP_FILTER_SUBSTRINGS = ((ber_tag_t) 0xa4U) // context specific + constructed
//!!! LDAP_FILTER_GE = ((ber_tag_t) 0xa5U) // context specific + constructed
//!!! LDAP_FILTER_LE = ((ber_tag_t) 0xa6U) // context specific + constructed
//!!! LDAP_FILTER_PRESENT = ((ber_tag_t) 0x87U) // context specific + primitive
//!!! LDAP_FILTER_APPROX = ((ber_tag_t) 0xa8U) // context specific + constructed
//!!! LDAP_FILTER_EXT = ((ber_tag_t) 0xa9U) // context specific + constructed
)
// extended filter component types
//!!! const (
LDAP_FILTER_EXT_OID = ((ber_tag_t) 0x81U) // context specific
//!!! LDAP_FILTER_EXT_TYPE = ((ber_tag_t) 0x82U) // context specific
//!!! LDAP_FILTER_EXT_VALUE = ((ber_tag_t) 0x83U) // context specific
//!!! LDAP_FILTER_EXT_DNATTRS = ((ber_tag_t) 0x84U) // context specific
)
// substring filter component types
//!!! const (
LDAP_SUBSTRING_INITIAL = ((ber_tag_t) 0x80U) // context specific
//!!! LDAP_SUBSTRING_ANY = ((ber_tag_t) 0x81U) // context specific
//!!! LDAP_SUBSTRING_FINAL = ((ber_tag_t) 0x82U) // context specific
)
// search scopes
//!!! const (
LDAP_SCOPE_BASE = ((ber_int_t) 0x0000)
LDAP_SCOPE_BASEOBJECT = LDAP_SCOPE_BASE
//!!! LDAP_SCOPE_ONELEVEL = ((ber_int_t) 0x0001)
LDAP_SCOPE_ONE = LDAP_SCOPE_ONELEVEL
//!!! LDAP_SCOPE_SUBTREE = ((ber_int_t) 0x0002)
LDAP_SCOPE_SUB = LDAP_SCOPE_SUBTREE
//!!! LDAP_SCOPE_SUBORDINATE = ((ber_int_t) 0x0003) // OpenLDAP extension
LDAP_SCOPE_CHILDREN = LDAP_SCOPE_SUBORDINATE
//!!! LDAP_SCOPE_DEFAULT = ((ber_int_t) -1) // OpenLDAP extension
)
// substring filter component types
//!!! const (
LDAP_SUBSTRING_INITIAL = ((ber_tag_t) 0x80U) // context specific
//!!! LDAP_SUBSTRING_ANY = ((ber_tag_t) 0x81U) // context specific
//!!! LDAP_SUBSTRING_FINAL = ((ber_tag_t) 0x82U) // context specific
)
//
// LDAP Result Codesconst LDAP_SUCCESS = 0x00
//!!! const LDAP_RANGE(n,x,y) = (((x) <= (n)) && ((n) <= (y)))
const (
LDAP_OPERATIONS_ERROR = 0x01
LDAP_PROTOCOL_ERROR = 0x02
LDAP_TIMELIMIT_EXCEEDED = 0x03
LDAP_SIZELIMIT_EXCEEDED = 0x04
LDAP_COMPARE_FALSE = 0x05
LDAP_COMPARE_TRUE = 0x06
LDAP_AUTH_METHOD_NOT_SUPPORTED = 0x07
LDAP_STRONG_AUTH_NOT_SUPPORTED = LDAP_AUTH_METHOD_NOT_SUPPORTED
LDAP_STRONG_AUTH_REQUIRED = 0x08
LDAP_STRONGER_AUTH_REQUIRED = LDAP_STRONG_AUTH_REQUIRED
LDAP_PARTIAL_RESULTS = 0x09 // LDAPv2+ (not LDAPv3)
)
const (
LDAP_REFERRAL = 0x0a // LDAPv3
LDAP_ADMINLIMIT_EXCEEDED = 0x0b // LDAPv3
LDAP_UNAVAILABLE_CRITICAL_EXTENSION = 0x0c // LDAPv3
LDAP_CONFIDENTIALITY_REQUIRED = 0x0d // LDAPv3
LDAP_SASL_BIND_IN_PROGRESS = 0x0e // LDAPv3
)
//!!! const LDAP_ATTR_ERROR(n) = LDAP_RANGE((n),0x10,0x15) // 16-21
const (
LDAP_NO_SUCH_ATTRIBUTE = 0x10
LDAP_UNDEFINED_TYPE = 0x11
LDAP_INAPPROPRIATE_MATCHING = 0x12
LDAP_CONSTRAINT_VIOLATION = 0x13
LDAP_TYPE_OR_VALUE_EXISTS = 0x14
LDAP_INVALID_SYNTAX = 0x15
)
//!!! const LDAP_NAME_ERROR(n) = LDAP_RANGE((n),0x20,0x24) // 32-34,36
const (
LDAP_NO_SUCH_OBJECT = 0x20
LDAP_ALIAS_PROBLEM = 0x21
LDAP_INVALID_DN_SYNTAX = 0x22
LDAP_IS_LEAF = 0x23 // not LDAPv3
LDAP_ALIAS_DEREF_PROBLEM = 0x24
)
//!!! const LDAP_SECURITY_ERROR(n) = LDAP_RANGE((n),0x2F,0x32) // 47-50
const (
LDAP_X_PROXY_AUTHZ_FAILURE = 0x2F // LDAPv3 proxy authorization
LDAP_INAPPROPRIATE_AUTH = 0x30
LDAP_INVALID_CREDENTIALS = 0x31
LDAP_INSUFFICIENT_ACCESS = 0x32
)
//!!! const LDAP_SERVICE_ERROR(n) = LDAP_RANGE((n),0x33,0x36) // 51-54
const (
LDAP_BUSY = 0x33
LDAP_UNAVAILABLE = 0x34
LDAP_UNWILLING_TO_PERFORM = 0x35
LDAP_LOOP_DETECT = 0x36
)
//!!! const LDAP_UPDATE_ERROR(n) = LDAP_RANGE((n),0x40,0x47) // 64-69,71
const (
LDAP_NAMING_VIOLATION = 0x40
LDAP_OBJECT_CLASS_VIOLATION = 0x41
LDAP_NOT_ALLOWED_ON_NONLEAF = 0x42
LDAP_NOT_ALLOWED_ON_RDN = 0x43
LDAP_ALREADY_EXISTS = 0x44
LDAP_NO_OBJECT_CLASS_MODS = 0x45
LDAP_RESULTS_TOO_LARGE = 0x46 // CLDAP
LDAP_AFFECTS_MULTIPLE_DSAS = 0x47
)
const LDAP_VLV_ERROR = 0x4C
const LDAP_OTHER = 0x50
// LCUP operation codes (113-117) - not implemented
const (
LDAP_CUP_RESOURCES_EXHAUSTED = 0x71
LDAP_CUP_SECURITY_VIOLATION = 0x72
LDAP_CUP_INVALID_DATA = 0x73
LDAP_CUP_UNSUPPORTED_SCHEME = 0x74
LDAP_CUP_RELOAD_REQUIRED = 0x75
)
// Cancel operation codes (118-121)
const (
LDAP_CANCELLED = 0x76
LDAP_NO_SUCH_OPERATION = 0x77
LDAP_TOO_LATE = 0x78
LDAP_CANNOT_CANCEL = 0x79
)
// Assertion control (122)
const LDAP_ASSERTION_FAILED = 0x7A
// Proxied Authorization Denied (123)
const LDAP_PROXIED_AUTHORIZATION_DENIED = 0x7B
// Experimental result codes
//!!! const LDAP_E_ERROR(n) = LDAP_RANGE((n),0x1000,0x3FFF)
// LDAP Sync (4096)
const LDAP_SYNC_REFRESH_REQUIRED = 0x1000
// Private Use result codes
//!!! const LDAP_X_ERROR(n) = LDAP_RANGE((n),0x4000,0xFFFF)
const (
LDAP_X_SYNC_REFRESH_REQUIRED = 0x4100 // defunct
LDAP_X_ASSERTION_FAILED = 0x410f // defunct
)
// for the LDAP No-Op control
const LDAP_X_NO_OPERATION = 0x410e
// for the Chaining Behavior control (consecutive result codes requested;// * see )
//!!! #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
const (
LDAP_X_NO_REFERRALS_FOUND = 0x4110
LDAP_X_CANNOT_CHAIN = 0x4111
//!!! #endif
)
// for Distributed Procedures (see )
//!!! #ifdef LDAP_X_DISTPROC_BASE
const LDAP_X_INVALIDREFERENCE = 0x4112
//!!! #endif
//!!! #ifdef LDAP_X_TXN
const (
LDAP_X_TXN_SPECIFY_OKAY = 0x4120
LDAP_X_TXN_ID_INVALID = 0x4121
//!!! #endif
)
// API Error Codes
// *
// Based on draft-ietf-ldap-c-api-xx
// but with new negative code values//!!! const (
LDAP_API_ERROR(n) = ((n)<0)
//!!! LDAP_API_RESULT(n) = ((n)<=0)
)
//!!! const (
LDAP_SERVER_DOWN = (-1)
//!!! LDAP_LOCAL_ERROR = (-2)
//!!! LDAP_ENCODING_ERROR = (-3)
//!!! LDAP_DECODING_ERROR = (-4)
//!!! LDAP_TIMEOUT = (-5)
//!!! LDAP_AUTH_UNKNOWN = (-6)
//!!! LDAP_FILTER_ERROR = (-7)
//!!! LDAP_USER_CANCELLED = (-8)
//!!! LDAP_PARAM_ERROR = (-9)
//!!! LDAP_NO_MEMORY = (-10)
//!!! LDAP_CONNECT_ERROR = (-11)
//!!! LDAP_NOT_SUPPORTED = (-12)
//!!! LDAP_CONTROL_NOT_FOUND = (-13)
//!!! LDAP_NO_RESULTS_RETURNED = (-14)
//!!! LDAP_MORE_RESULTS_TO_RETURN = (-15) // Obsolete
//!!! LDAP_CLIENT_LOOP = (-16)
//!!! LDAP_REFERRAL_LIMIT_EXCEEDED = (-17)
//!!! LDAP_X_CONNECTING = (-18)
)
//
// This structure represents both ldap messages and ldap responses.
// These are really the same, except in the case of search responses,
// where a response has multiple messages.
//!!! type LDAPMessage struct ldapmsg
// for modifications
//!!! typedef struct ldapmod {
//!!! int mod_op;
//!!! const (
LDAP_MOD_OP = (0x0007)
//!!! LDAP_MOD_ADD = (0x0000)
//!!! LDAP_MOD_DELETE = (0x0001)
//!!! LDAP_MOD_REPLACE = (0x0002)
//!!! LDAP_MOD_INCREMENT = (0x0003) // OpenLDAP extension
//!!! LDAP_MOD_BVALUES = (0x0080)
// IMPORTANT: do not use code 0x1000 (or above),
// it is used internally by the backends!
// (see ldap/servers/slapd/slap.h))
//!!! char *mod_type;
//!!! union mod_vals_u {
//!!! char **modv_strvals;
//!!! struct berval **modv_bvals;
//!!! } mod_vals;
const (
mod_values = mod_vals.modv_strvals
mod_bvalues = mod_vals.modv_bvals
//!!! } LDAPMod;
)
//
// structure representing an ldap session which can
// encompass connections to multiple servers (in the
// face of referrals).//!!! type LDAP struct ldap
const (
LDAP_DEREF_NEVER = 0x00
LDAP_DEREF_SEARCHING = 0x01
LDAP_DEREF_FINDING = 0x02
LDAP_DEREF_ALWAYS = 0x03
)
const LDAP_NO_LIMIT = 0
// how many messages to retrieve results for
const (
LDAP_MSG_ONE = 0x00
LDAP_MSG_ALL = 0x01
LDAP_MSG_RECEIVED = 0x02
)
//
// types for ldap URL handling//!!! typedef struct ldap_url_desc {
//!!! struct ldap_url_desc *lud_next;
//!!! char *lud_scheme;
//!!! char *lud_host;
//!!! int lud_port;
//!!! char *lud_dn;
//!!! char **lud_attrs;
//!!! int lud_scope;
//!!! char *lud_filter;
//!!! char **lud_exts;
//!!! int lud_crit_exts;
//!!! } LDAPURLDesc;
const (
LDAP_URL_SUCCESS = 0x00 // Success
LDAP_URL_ERR_MEM = 0x01 // can't allocate memory space
LDAP_URL_ERR_PARAM = 0x02 // parameter is bad
)
const (
LDAP_URL_ERR_BADSCHEME = 0x03 // URL doesn't begin with "ldap[si]://"
LDAP_URL_ERR_BADENCLOSURE = 0x04 // URL is missing trailing ">"
LDAP_URL_ERR_BADURL = 0x05 // URL is bad
LDAP_URL_ERR_BADHOST = 0x06 // host port is bad
LDAP_URL_ERR_BADATTRS = 0x07 // bad (or missing) attributes
LDAP_URL_ERR_BADSCOPE = 0x08 // scope string is invalid (or missing)
LDAP_URL_ERR_BADFILTER = 0x09 // bad or missing filter
LDAP_URL_ERR_BADEXTS = 0x0a // bad or missing extensions
)
//
// LDAP sync (RFC4533) API
//!!! type ldap_sync_t struct ldap_sync_t
//!!! typedef enum {
// these are private - the client should never see them
//!!! LDAP_SYNC_CAPI_NONE = -1,
//!!! LDAP_SYNC_CAPI_PHASE_FLAG = 0x10U,
//!!! LDAP_SYNC_CAPI_IDSET_FLAG = 0x20U,
//!!! LDAP_SYNC_CAPI_DONE_FLAG = 0x40U,
// these are passed to ls_search_entry()
//!!! LDAP_SYNC_CAPI_PRESENT = LDAP_SYNC_PRESENT,
//!!! LDAP_SYNC_CAPI_ADD = LDAP_SYNC_ADD,
//!!! LDAP_SYNC_CAPI_MODIFY = LDAP_SYNC_MODIFY,
//!!! LDAP_SYNC_CAPI_DELETE = LDAP_SYNC_DELETE,
// these are passed to ls_intermediate()
//!!! LDAP_SYNC_CAPI_PRESENTS = ( LDAP_SYNC_CAPI_PHASE_FLAG | LDAP_SYNC_CAPI_PRESENT ),
//!!! LDAP_SYNC_CAPI_DELETES = ( LDAP_SYNC_CAPI_PHASE_FLAG | LDAP_SYNC_CAPI_DELETE ),
//!!! LDAP_SYNC_CAPI_PRESENTS_IDSET = ( LDAP_SYNC_CAPI_PRESENTS | LDAP_SYNC_CAPI_IDSET_FLAG ),
//!!! LDAP_SYNC_CAPI_DELETES_IDSET = ( LDAP_SYNC_CAPI_DELETES | LDAP_SYNC_CAPI_IDSET_FLAG ),
//!!! LDAP_SYNC_CAPI_DONE = ( LDAP_SYNC_CAPI_DONE_FLAG | LDAP_SYNC_CAPI_PRESENTS )
//!!! } ldap_sync_refresh_t;
//
// Called when an entry is returned by ldap_result().
// If phase is LDAP_SYNC_CAPI_ADD or LDAP_SYNC_CAPI_MODIFY,
// the entry has been either added or modified, and thus
// the complete view of the entry should be in the LDAPMessage.
// If phase is LDAP_SYNC_CAPI_PRESENT or LDAP_SYNC_CAPI_DELETE,
// only the DN should be in the LDAPMessage.
//!!! typedef int (*ldap_sync_search_entry_f) LDAP_P((
//!!! ldap_sync_t *ls,
//!!! LDAPMessage *msg,
//!!! struct berval *entryUUID,
//!!! ldap_sync_refresh_t phase ));
//
// Called when a reference is returned; the client should know
// what to do with it.
//!!! typedef int (*ldap_sync_search_reference_f) LDAP_P((
//!!! ldap_sync_t *ls,
//!!! LDAPMessage *msg ));
//
// Called when specific intermediate/final messages are returned.
// If phase is LDAP_SYNC_CAPI_PRESENTS or LDAP_SYNC_CAPI_DELETES,
// a "presents" or "deletes" phase begins.
// If phase is LDAP_SYNC_CAPI_DONE, a special "presents" phase
// with refreshDone set to "TRUE" has been returned, to indicate
// that the refresh phase of a refreshAndPersist is complete.
// In the above cases, syncUUIDs is NULL.
// *
// If phase is LDAP_SYNC_CAPI_PRESENTS_IDSET or
// LDAP_SYNC_CAPI_DELETES_IDSET, syncUUIDs is an array of UUIDs
// that are either present or have been deleted.
//!!! typedef int (*ldap_sync_intermediate_f) LDAP_P((
//!!! ldap_sync_t *ls,
//!!! LDAPMessage *msg,
//!!! BerVarray syncUUIDs,
//!!! ldap_sync_refresh_t phase ));
//
// Called when a searchResultDone is returned. In refreshAndPersist,
// this can only occur if the search for any reason is being terminated
// by the server.
//!!! typedef int (*ldap_sync_search_result_f) LDAP_P((
//!!! ldap_sync_t *ls,
//!!! LDAPMessage *msg,
//!!! int refreshDeletes ));
//
// This structure contains all information about the persistent search;
// the caller is responsible for connecting, setting version, binding, tls...
// type Ldap_sync_t struct {
// conf search params
//!!! Base char
//!!! Scope int
//!!! Filter char
//!!! Attrs char
//!!! Timelimit int
//!!! Sizelimit int
// poll timeout
//!!! Timeout int
// helpers - add as appropriate
//!!! Search_entry ldap_sync_search_entry_f
//!!! Search_reference ldap_sync_search_reference_f
//!!! Intermediate ldap_sync_intermediate_f
//!!! Search_result ldap_sync_search_result_f
// set by the caller as appropriate
//!!! Private void
// conn stuff
//!!! Ld LDAP
// --- the parameters below are private - do not modify ---
// FIXME: make the structure opaque, and provide an interface// * to modify the public values?
// result stuff
//!!! Msgid int
// sync stuff
// needed by refreshOnly
//!!! ReloadHint int
// opaque - need to pass between sessions, updated by the API
//!!! Cookie struct berval
// state variable - do not modify
//!!! RefreshPhase ldap_sync_refresh_t
}
//
// End of LDAP sync (RFC4533) API
//
// Connection callbacks...//!!! struct ldap_conncb;
//!!! struct sockaddr;
// Called after a connection is established
//!!! typedef int (ldap_conn_add_f) LDAP_P(( LDAP *ld, Sockbuf *sb, LDAPURLDesc *srv, struct sockaddr *addr,
//!!! struct ldap_conncb *ctx ));
// Called before a connection is closed
//!!! type )) void (ldap_conn_del_f) LDAP_P(( LDAP *ld, Sockbuf *sb, struct ldap_conncb *ctx
// Callbacks are pushed on a stack. Last one pushed is first one executed. The
// delete callback is called with a NULL Sockbuf just before freeing the LDAP handle.//!!! typedef struct ldap_conncb {
//!!! ldap_conn_add_f *lc_add;
//!!! ldap_conn_del_f *lc_del;
//!!! void *lc_arg;
//!!! } ldap_conncb;
//
// The API draft spec says we should declare (or cause to be declared)
// 'struct timeval'. We don't. See IETF LDAPext discussions.//!!! struct timeval;
//
// in options.c://!!! LDAP_F( int )
//!!! ldap_get_option LDAP_P((
//!!! LDAP *ld,
//!!! int option,
//!!! void *outvalue));
//!!! LDAP_F( int )
//!!! ldap_set_option LDAP_P((
//!!! LDAP *ld,
//!!! int option,
//!!! LDAP_CONST void *invalue));
// V3 REBIND Function Callback Prototype
//!!! typedef int (LDAP_REBIND_PROC) LDAP_P((
//!!! LDAP *ld, LDAP_CONST char *url,
//!!! ber_tag_t request, ber_int_t msgid,
//!!! void *params ));
//!!! LDAP_F( int )
//!!! ldap_set_rebind_proc LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_REBIND_PROC *rebind_proc,
//!!! void *params ));
// V3 referral selection Function Callback Prototype
//!!! typedef int (LDAP_NEXTREF_PROC) LDAP_P((
//!!! LDAP *ld, char ***refsp, int *cntp,
//!!! void *params ));
//!!! LDAP_F( int )
//!!! ldap_set_nextref_proc LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_NEXTREF_PROC *nextref_proc,
//!!! void *params ));
// V3 URLLIST Function Callback Prototype
//!!! typedef int (LDAP_URLLIST_PROC) LDAP_P((
//!!! LDAP *ld,
//!!! LDAPURLDesc **urllist,
//!!! LDAPURLDesc **url,
//!!! void *params ));
//!!! LDAP_F( int )
//!!! ldap_set_urllist_proc LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_URLLIST_PROC *urllist_proc,
//!!! void *params ));
//
// in controls.c://!!! #if LDAP_DEPRECATED
//!!! LDAP_F( int )
//!!! ldap_create_control LDAP_P(( // deprecated, use ldap_control_create
//!!! LDAP_CONST char *requestOID,
//!!! BerElement *ber,
//!!! int iscritical,
//!!! LDAPControl **ctrlp ));
//!!! LDAP_F( LDAPControl * )
//!!! ldap_find_control LDAP_P(( // deprecated, use ldap_control_find
//!!! LDAP_CONST char *oid,
//!!! LDAPControl **ctrls ));
//!!! #endif
//!!! LDAP_F( int )
//!!! ldap_control_create LDAP_P((
//!!! LDAP_CONST char *requestOID,
//!!! int iscritical,
//!!! struct berval *value,
//!!! int dupval,
//!!! LDAPControl **ctrlp ));
//!!! LDAP_F( LDAPControl * )
//!!! ldap_control_find LDAP_P((
//!!! LDAP_CONST char *oid,
//!!! LDAPControl **ctrls,
//!!! LDAPControl ***nextctrlp ));
//!!! LDAP_F( void )
//!!! ldap_control_free LDAP_P((
//!!! LDAPControl *ctrl ));
//!!! LDAP_F( void )
//!!! ldap_controls_free LDAP_P((
//!!! LDAPControl **ctrls ));
//!!! LDAP_F( LDAPControl ** )
//!!! ldap_controls_dup LDAP_P((
//!!! LDAPControl *LDAP_CONST *controls ));
//!!! LDAP_F( LDAPControl * )
//!!! ldap_control_dup LDAP_P((
//!!! LDAP_CONST LDAPControl *c ));
//
// in dnssrv.c://!!! LDAP_F( int )
//!!! ldap_domain2dn LDAP_P((
//!!! LDAP_CONST char* domain,
//!!! char** dn ));
//!!! LDAP_F( int )
//!!! ldap_dn2domain LDAP_P((
//!!! LDAP_CONST char* dn,
//!!! char** domain ));
//!!! LDAP_F( int )
//!!! ldap_domain2hostlist LDAP_P((
//!!! LDAP_CONST char *domain,
//!!! char** hostlist ));
//
// in extended.c://!!! LDAP_F( int )
//!!! ldap_extended_operation LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *reqoid,
//!!! struct berval *reqdata,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls,
//!!! int *msgidp ));
//!!! LDAP_F( int )
//!!! ldap_extended_operation_s LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *reqoid,
//!!! struct berval *reqdata,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls,
//!!! char **retoidp,
//!!! struct berval **retdatap ));
//!!! LDAP_F( int )
//!!! ldap_parse_extended_result LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *res,
//!!! char **retoidp,
//!!! struct berval **retdatap,
//!!! int freeit ));
//!!! LDAP_F( int )
//!!! ldap_parse_intermediate LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *res,
//!!! char **retoidp,
//!!! struct berval **retdatap,
//!!! LDAPControl ***serverctrls,
//!!! int freeit ));
//
// in abandon.c://!!! LDAP_F( int )
//!!! ldap_abandon_ext LDAP_P((
//!!! LDAP *ld,
//!!! int msgid,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls ));
//!!! #if LDAP_DEPRECATED
//!!! LDAP_F( int )
//!!! ldap_abandon LDAP_P(( // deprecated, use ldap_abandon_ext
//!!! LDAP *ld,
//!!! int msgid ));
//!!! #endif
//
// in add.c://!!! LDAP_F( int )
//!!! ldap_add_ext LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAPMod **attrs,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls,
//!!! int *msgidp ));
//!!! LDAP_F( int )
//!!! ldap_add_ext_s LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAPMod **attrs,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls ));
//!!! #if LDAP_DEPRECATED
//!!! LDAP_F( int )
//!!! ldap_add LDAP_P(( // deprecated, use ldap_add_ext
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAPMod **attrs ));
//!!! LDAP_F( int )
//!!! ldap_add_s LDAP_P(( // deprecated, use ldap_add_ext_s
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAPMod **attrs ));
//!!! #endif
//
// in sasl.c://!!! LDAP_F( int )
//!!! ldap_sasl_bind LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAP_CONST char *mechanism,
//!!! struct berval *cred,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls,
//!!! int *msgidp ));
// Interaction flags (should be passed about in a control)
// Automatic (default): use defaults, prompt otherwise
// Interactive: prompt always
// Quiet: never promptconst (
LDAP_SASL_AUTOMATIC = 0U
LDAP_SASL_INTERACTIVE = 1U
LDAP_SASL_QUIET = 2U
)
//
// V3 SASL Interaction Function Callback Prototype
// when using Cyrus SASL, interact is pointer to sasl_interact_t
// should likely passed in a control (and provided controls)//!!! typedef int (LDAP_SASL_INTERACT_PROC) LDAP_P((
//!!! LDAP *ld, unsigned flags, void* defaults, void *interact ));
//!!! LDAP_F( int )
//!!! ldap_sasl_interactive_bind LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn, // usually NULL
//!!! LDAP_CONST char *saslMechanism,
//!!! LDAPControl **serverControls,
//!!! LDAPControl **clientControls,
// should be client controls
//!!! unsigned flags,
//!!! LDAP_SASL_INTERACT_PROC *proc,
//!!! void *defaults,
// as obtained from ldap_result()
//!!! LDAPMessage *result,
// returned during bind processing
//!!! const char **rmech,
//!!! int *msgid ));
//!!! LDAP_F( int )
//!!! ldap_sasl_interactive_bind_s LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn, // usually NULL
//!!! LDAP_CONST char *saslMechanism,
//!!! LDAPControl **serverControls,
//!!! LDAPControl **clientControls,
// should be client controls
//!!! unsigned flags,
//!!! LDAP_SASL_INTERACT_PROC *proc,
//!!! void *defaults ));
//!!! LDAP_F( int )
//!!! ldap_sasl_bind_s LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAP_CONST char *mechanism,
//!!! struct berval *cred,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls,
//!!! struct berval **servercredp ));
//!!! LDAP_F( int )
//!!! ldap_parse_sasl_bind_result LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *res,
//!!! struct berval **servercredp,
//!!! int freeit ));
//!!! #if LDAP_DEPRECATED
//
// in bind.c:
// (deprecated)//!!! LDAP_F( int )
//!!! ldap_bind LDAP_P(( // deprecated, use ldap_sasl_bind
//!!! LDAP *ld,
//!!! LDAP_CONST char *who,
//!!! LDAP_CONST char *passwd,
//!!! int authmethod ));
//!!! LDAP_F( int )
//!!! ldap_bind_s LDAP_P(( // deprecated, use ldap_sasl_bind_s
//!!! LDAP *ld,
//!!! LDAP_CONST char *who,
//!!! LDAP_CONST char *cred,
//!!! int authmethod ));
//
// in sbind.c://!!! LDAP_F( int )
//!!! ldap_simple_bind LDAP_P(( // deprecated, use ldap_sasl_bind
//!!! LDAP *ld,
//!!! LDAP_CONST char *who,
//!!! LDAP_CONST char *passwd ));
//!!! LDAP_F( int )
//!!! ldap_simple_bind_s LDAP_P(( // deprecated, use ldap_sasl_bind_s
//!!! LDAP *ld,
//!!! LDAP_CONST char *who,
//!!! LDAP_CONST char *passwd ));
//!!! #endif
//
// in compare.c://!!! LDAP_F( int )
//!!! ldap_compare_ext LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAP_CONST char *attr,
//!!! struct berval *bvalue,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls,
//!!! int *msgidp ));
//!!! LDAP_F( int )
//!!! ldap_compare_ext_s LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAP_CONST char *attr,
//!!! struct berval *bvalue,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls ));
//!!! #if LDAP_DEPRECATED
//!!! LDAP_F( int )
//!!! ldap_compare LDAP_P(( // deprecated, use ldap_compare_ext
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAP_CONST char *attr,
//!!! LDAP_CONST char *value ));
//!!! LDAP_F( int )
//!!! ldap_compare_s LDAP_P(( // deprecated, use ldap_compare_ext_s
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAP_CONST char *attr,
//!!! LDAP_CONST char *value ));
//!!! #endif
//
// in delete.c://!!! LDAP_F( int )
//!!! ldap_delete_ext LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls,
//!!! int *msgidp ));
//!!! LDAP_F( int )
//!!! ldap_delete_ext_s LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls ));
//!!! #if LDAP_DEPRECATED
//!!! LDAP_F( int )
//!!! ldap_delete LDAP_P(( // deprecated, use ldap_delete_ext
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn ));
//!!! LDAP_F( int )
//!!! ldap_delete_s LDAP_P(( // deprecated, use ldap_delete_ext_s
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn ));
//!!! #endif
//
// in error.c://!!! LDAP_F( int )
//!!! ldap_parse_result LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *res,
//!!! int *errcodep,
//!!! char **matcheddnp,
//!!! char **errmsgp,
//!!! char ***referralsp,
//!!! LDAPControl ***serverctrls,
//!!! int freeit ));
//!!! LDAP_F( char * )
//!!! ldap_err2string LDAP_P((
//!!! int err ));
//!!! #if LDAP_DEPRECATED
//!!! LDAP_F( int )
//!!! ldap_result2error LDAP_P(( // deprecated, use ldap_parse_result
//!!! LDAP *ld,
//!!! LDAPMessage *r,
//!!! int freeit ));
//!!! LDAP_F( void )
//!!! ldap_perror LDAP_P(( // deprecated, use ldap_err2string
//!!! LDAP *ld,
//!!! LDAP_CONST char *s ));
//!!! #endif
//
// gssapi.c://!!! LDAP_F( int )
//!!! ldap_gssapi_bind LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAP_CONST char *creds ));
//!!! LDAP_F( int )
//!!! ldap_gssapi_bind_s LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAP_CONST char *creds ));
//
// in modify.c://!!! LDAP_F( int )
//!!! ldap_modify_ext LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAPMod **mods,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls,
//!!! int *msgidp ));
//!!! LDAP_F( int )
//!!! ldap_modify_ext_s LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAPMod **mods,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls ));
//!!! #if LDAP_DEPRECATED
//!!! LDAP_F( int )
//!!! ldap_modify LDAP_P(( // deprecated, use ldap_modify_ext
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAPMod **mods ));
//!!! LDAP_F( int )
//!!! ldap_modify_s LDAP_P(( // deprecated, use ldap_modify_ext_s
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAPMod **mods ));
//!!! #endif
//
// in modrdn.c://!!! LDAP_F( int )
//!!! ldap_rename LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAP_CONST char *newrdn,
//!!! LDAP_CONST char *newSuperior,
//!!! int deleteoldrdn,
//!!! LDAPControl **sctrls,
//!!! LDAPControl **cctrls,
//!!! int *msgidp ));
//!!! LDAP_F( int )
//!!! ldap_rename_s LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAP_CONST char *newrdn,
//!!! LDAP_CONST char *newSuperior,
//!!! int deleteoldrdn,
//!!! LDAPControl **sctrls,
//!!! LDAPControl **cctrls ));
//!!! #if LDAP_DEPRECATED
//!!! LDAP_F( int )
//!!! ldap_rename2 LDAP_P(( // deprecated, use ldap_rename
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAP_CONST char *newrdn,
//!!! LDAP_CONST char *newSuperior,
//!!! int deleteoldrdn ));
//!!! LDAP_F( int )
//!!! ldap_rename2_s LDAP_P(( // deprecated, use ldap_rename_s
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAP_CONST char *newrdn,
//!!! LDAP_CONST char *newSuperior,
//!!! int deleteoldrdn ));
//!!! LDAP_F( int )
//!!! ldap_modrdn LDAP_P(( // deprecated, use ldap_rename
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAP_CONST char *newrdn ));
//!!! LDAP_F( int )
//!!! ldap_modrdn_s LDAP_P(( // deprecated, use ldap_rename_s
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAP_CONST char *newrdn ));
//!!! LDAP_F( int )
//!!! ldap_modrdn2 LDAP_P(( // deprecated, use ldap_rename
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAP_CONST char *newrdn,
//!!! int deleteoldrdn ));
//!!! LDAP_F( int )
//!!! ldap_modrdn2_s LDAP_P(( // deprecated, use ldap_rename_s
//!!! LDAP *ld,
//!!! LDAP_CONST char *dn,
//!!! LDAP_CONST char *newrdn,
//!!! int deleteoldrdn));
//!!! #endif
//
// in open.c://!!! #if LDAP_DEPRECATED
//!!! LDAP_F( LDAP * )
//!!! ldap_init LDAP_P(( // deprecated, use ldap_create or ldap_initialize
//!!! LDAP_CONST char *host,
//!!! int port ));
//!!! LDAP_F( LDAP * )
//!!! ldap_open LDAP_P(( // deprecated, use ldap_create or ldap_initialize
//!!! LDAP_CONST char *host,
//!!! int port ));
//!!! #endif
//!!! LDAP_F( int )
//!!! ldap_create LDAP_P((
//!!! LDAP **ldp ));
//!!! LDAP_F( int )
//!!! ldap_initialize LDAP_P((
//!!! LDAP **ldp,
//!!! LDAP_CONST char *url ));
//!!! LDAP_F( LDAP * )
//!!! ldap_dup LDAP_P((
//!!! LDAP *old ));
//
// in tls.c
//!!! LDAP_F( int )
//!!! ldap_tls_inplace LDAP_P((
//!!! LDAP *ld ));
//!!! LDAP_F( int )
//!!! ldap_start_tls LDAP_P((
//!!! LDAP *ld,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls,
//!!! int *msgidp ));
//!!! LDAP_F( int )
//!!! ldap_install_tls LDAP_P((
//!!! LDAP *ld ));
//!!! LDAP_F( int )
//!!! ldap_start_tls_s LDAP_P((
//!!! LDAP *ld,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls ));
//
// in messages.c://!!! LDAP_F( LDAPMessage * )
//!!! ldap_first_message LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *chain ));
//!!! LDAP_F( LDAPMessage * )
//!!! ldap_next_message LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *msg ));
//!!! LDAP_F( int )
//!!! ldap_count_messages LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *chain ));
//
// in references.c://!!! LDAP_F( LDAPMessage * )
//!!! ldap_first_reference LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *chain ));
//!!! LDAP_F( LDAPMessage * )
//!!! ldap_next_reference LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *ref ));
//!!! LDAP_F( int )
//!!! ldap_count_references LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *chain ));
//!!! LDAP_F( int )
//!!! ldap_parse_reference LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *ref,
//!!! char ***referralsp,
//!!! LDAPControl ***serverctrls,
//!!! int freeit));
//
// in getentry.c://!!! LDAP_F( LDAPMessage * )
//!!! ldap_first_entry LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *chain ));
//!!! LDAP_F( LDAPMessage * )
//!!! ldap_next_entry LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *entry ));
//!!! LDAP_F( int )
//!!! ldap_count_entries LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *chain ));
//!!! LDAP_F( int )
//!!! ldap_get_entry_controls LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *entry,
//!!! LDAPControl ***serverctrls));
//
// in addentry.c//!!! LDAP_F( LDAPMessage * )
//!!! ldap_delete_result_entry LDAP_P((
//!!! LDAPMessage **list,
//!!! LDAPMessage *e ));
//!!! LDAP_F( void )
//!!! ldap_add_result_entry LDAP_P((
//!!! LDAPMessage **list,
//!!! LDAPMessage *e ));
//
// in getdn.c//!!! LDAP_F( char * )
//!!! ldap_get_dn LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *entry ));
//!!! typedef struct ldap_ava {
//!!! struct berval la_attr;
//!!! struct berval la_value;
//!!! unsigned la_flags;
const (
LDAP_AVA_NULL = 0x0000U
LDAP_AVA_STRING = 0x0001U
LDAP_AVA_BINARY = 0x0002U
LDAP_AVA_NONPRINTABLE = 0x0004U
LDAP_AVA_FREE_ATTR = 0x0010U
LDAP_AVA_FREE_VALUE = 0x0020U
)
//!!! void *la_private;
//!!! } LDAPAVA;
//!!! type (
LDAPRDN LDAPAVA**
//!!! LDAPDN LDAPRDN*
)
// DN formats
const (
LDAP_DN_FORMAT_LDAP = 0x0000U
LDAP_DN_FORMAT_LDAPV3 = 0x0010U
LDAP_DN_FORMAT_LDAPV2 = 0x0020U
LDAP_DN_FORMAT_DCE = 0x0030U
LDAP_DN_FORMAT_UFN = 0x0040U // dn2str only
LDAP_DN_FORMAT_AD_CANONICAL = 0x0050U // dn2str only
LDAP_DN_FORMAT_LBER = 0x00F0U // for testing only
LDAP_DN_FORMAT_MASK = 0x00F0U
)
// DN flags
const (
LDAP_DN_PRETTY = 0x0100U
LDAP_DN_SKIP = 0x0200U
LDAP_DN_P_NOLEADTRAILSPACES = 0x1000U
LDAP_DN_P_NOSPACEAFTERRDN = 0x2000U
LDAP_DN_PEDANTIC = 0xF000U
)
//!!! LDAP_F( void ) ldap_rdnfree LDAP_P(( LDAPRDN rdn ));
//!!! LDAP_F( void ) ldap_dnfree LDAP_P(( LDAPDN dn ));
//!!! LDAP_F( int )
//!!! ldap_bv2dn LDAP_P((
//!!! struct berval *bv,
//!!! LDAPDN *dn,
//!!! unsigned flags ));
//!!! LDAP_F( int )
//!!! ldap_str2dn LDAP_P((
//!!! LDAP_CONST char *str,
//!!! LDAPDN *dn,
//!!! unsigned flags ));
//!!! LDAP_F( int )
//!!! ldap_dn2bv LDAP_P((
//!!! LDAPDN dn,
//!!! struct berval *bv,
//!!! unsigned flags ));
//!!! LDAP_F( int )
//!!! ldap_dn2str LDAP_P((
//!!! LDAPDN dn,
//!!! char **str,
//!!! unsigned flags ));
//!!! LDAP_F( int )
//!!! ldap_bv2rdn LDAP_P((
//!!! struct berval *bv,
//!!! LDAPRDN *rdn,
//!!! char **next,
//!!! unsigned flags ));
//!!! LDAP_F( int )
//!!! ldap_str2rdn LDAP_P((
//!!! LDAP_CONST char *str,
//!!! LDAPRDN *rdn,
//!!! char **next,
//!!! unsigned flags ));
//!!! LDAP_F( int )
//!!! ldap_rdn2bv LDAP_P((
//!!! LDAPRDN rdn,
//!!! struct berval *bv,
//!!! unsigned flags ));
//!!! LDAP_F( int )
//!!! ldap_rdn2str LDAP_P((
//!!! LDAPRDN rdn,
//!!! char **str,
//!!! unsigned flags ));
//!!! LDAP_F( int )
//!!! ldap_dn_normalize LDAP_P((
//!!! LDAP_CONST char *in, unsigned iflags,
//!!! char **out, unsigned oflags ));
//!!! LDAP_F( char * )
//!!! ldap_dn2ufn LDAP_P(( // deprecated, use ldap_str2dn/dn2str
//!!! LDAP_CONST char *dn ));
//!!! LDAP_F( char ** )
//!!! ldap_explode_dn LDAP_P(( // deprecated, ldap_str2dn
//!!! LDAP_CONST char *dn,
//!!! int notypes ));
//!!! LDAP_F( char ** )
//!!! ldap_explode_rdn LDAP_P(( // deprecated, ldap_str2rdn
//!!! LDAP_CONST char *rdn,
//!!! int notypes ));
//!!! typedef int LDAPDN_rewrite_func
//!!! LDAP_P(( LDAPDN dn, unsigned flags, void *ctx ));
//!!! LDAP_F( int )
//!!! ldap_X509dn2bv LDAP_P(( void *x509_name, struct berval *dn,
//!!! LDAPDN_rewrite_func *func, unsigned flags ));
//!!! LDAP_F( char * )
//!!! ldap_dn2dcedn LDAP_P(( // deprecated, ldap_str2dn/dn2str
//!!! LDAP_CONST char *dn ));
//!!! LDAP_F( char * )
//!!! ldap_dcedn2dn LDAP_P(( // deprecated, ldap_str2dn/dn2str
//!!! LDAP_CONST char *dce ));
//!!! LDAP_F( char * )
//!!! ldap_dn2ad_canonical LDAP_P(( // deprecated, ldap_str2dn/dn2str
//!!! LDAP_CONST char *dn ));
//!!! LDAP_F( int )
//!!! ldap_get_dn_ber LDAP_P((
//!!! LDAP *ld, LDAPMessage *e, BerElement **berout, struct berval *dn ));
//!!! LDAP_F( int )
//!!! ldap_get_attribute_ber LDAP_P((
//!!! LDAP *ld, LDAPMessage *e, BerElement *ber, struct berval *attr,
//!!! struct berval **vals ));
//
// in getattr.c//!!! LDAP_F( char * )
//!!! ldap_first_attribute LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *entry,
//!!! BerElement **ber ));
//!!! LDAP_F( char * )
//!!! ldap_next_attribute LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *entry,
//!!! BerElement *ber ));
//
// in getvalues.c//!!! LDAP_F( struct berval ** )
//!!! ldap_get_values_len LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *entry,
//!!! LDAP_CONST char *target ));
//!!! LDAP_F( int )
//!!! ldap_count_values_len LDAP_P((
//!!! struct berval **vals ));
//!!! LDAP_F( void )
//!!! ldap_value_free_len LDAP_P((
//!!! struct berval **vals ));
//!!! #if LDAP_DEPRECATED
//!!! LDAP_F( char ** )
//!!! ldap_get_values LDAP_P(( // deprecated, use ldap_get_values_len
//!!! LDAP *ld,
//!!! LDAPMessage *entry,
//!!! LDAP_CONST char *target ));
//!!! LDAP_F( int )
//!!! ldap_count_values LDAP_P(( // deprecated, use ldap_count_values_len
//!!! char **vals ));
//!!! LDAP_F( void )
//!!! ldap_value_free LDAP_P(( // deprecated, use ldap_value_free_len
//!!! char **vals ));
//!!! #endif
//
// in result.c://!!! LDAP_F( int )
//!!! ldap_result LDAP_P((
//!!! LDAP *ld,
//!!! int msgid,
//!!! int all,
//!!! struct timeval *timeout,
//!!! LDAPMessage **result ));
//!!! LDAP_F( int )
//!!! ldap_msgtype LDAP_P((
//!!! LDAPMessage *lm ));
//!!! LDAP_F( int )
//!!! ldap_msgid LDAP_P((
//!!! LDAPMessage *lm ));
//!!! LDAP_F( int )
//!!! ldap_msgfree LDAP_P((
//!!! LDAPMessage *lm ));
//!!! LDAP_F( int )
//!!! ldap_msgdelete LDAP_P((
//!!! LDAP *ld,
//!!! int msgid ));
//
// in search.c://!!! LDAP_F( int )
//!!! ldap_bv2escaped_filter_value LDAP_P((
//!!! struct berval *in,
//!!! struct berval *out ));
//!!! LDAP_F( int )
//!!! ldap_search_ext LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *base,
//!!! int scope,
//!!! LDAP_CONST char *filter,
//!!! char **attrs,
//!!! int attrsonly,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls,
//!!! struct timeval *timeout,
//!!! int sizelimit,
//!!! int *msgidp ));
//!!! LDAP_F( int )
//!!! ldap_search_ext_s LDAP_P((
//!!! LDAP *ld,
//!!! LDAP_CONST char *base,
//!!! int scope,
//!!! LDAP_CONST char *filter,
//!!! char **attrs,
//!!! int attrsonly,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls,
//!!! struct timeval *timeout,
//!!! int sizelimit,
//!!! LDAPMessage **res ));
//!!! #if LDAP_DEPRECATED
//!!! LDAP_F( int )
//!!! ldap_search LDAP_P(( // deprecated, use ldap_search_ext
//!!! LDAP *ld,
//!!! LDAP_CONST char *base,
//!!! int scope,
//!!! LDAP_CONST char *filter,
//!!! char **attrs,
//!!! int attrsonly ));
//!!! LDAP_F( int )
//!!! ldap_search_s LDAP_P(( // deprecated, use ldap_search_ext_s
//!!! LDAP *ld,
//!!! LDAP_CONST char *base,
//!!! int scope,
//!!! LDAP_CONST char *filter,
//!!! char **attrs,
//!!! int attrsonly,
//!!! LDAPMessage **res ));
//!!! LDAP_F( int )
//!!! ldap_search_st LDAP_P(( // deprecated, use ldap_search_ext_s
//!!! LDAP *ld,
//!!! LDAP_CONST char *base,
//!!! int scope,
//!!! LDAP_CONST char *filter,
//!!! char **attrs,
//!!! int attrsonly,
//!!! struct timeval *timeout,
//!!! LDAPMessage **res ));
//!!! #endif
//
// in unbind.c//!!! LDAP_F( int )
//!!! ldap_unbind_ext LDAP_P((
//!!! LDAP *ld,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls));
//!!! LDAP_F( int )
//!!! ldap_unbind_ext_s LDAP_P((
//!!! LDAP *ld,
//!!! LDAPControl **serverctrls,
//!!! LDAPControl **clientctrls));
//!!! LDAP_F( int )
//!!! ldap_destroy LDAP_P((
//!!! LDAP *ld));
//!!! #if LDAP_DEPRECATED
//!!! LDAP_F( int )
//!!! ldap_unbind LDAP_P(( // deprecated, use ldap_unbind_ext
//!!! LDAP *ld ));
//!!! LDAP_F( int )
//!!! ldap_unbind_s LDAP_P(( // deprecated, use ldap_unbind_ext_s
//!!! LDAP *ld ));
//!!! #endif
//
// in filter.c//!!! LDAP_F( int )
//!!! ldap_put_vrFilter LDAP_P((
//!!! BerElement *ber,
//!!! const char *vrf ));
//
// in free.c
//!!! LDAP_F( void * )
//!!! ldap_memalloc LDAP_P((
//!!! ber_len_t s ));
//!!! LDAP_F( void * )
//!!! ldap_memrealloc LDAP_P((
//!!! void* p,
//!!! ber_len_t s ));
//!!! LDAP_F( void * )
//!!! ldap_memcalloc LDAP_P((
//!!! ber_len_t n,
//!!! ber_len_t s ));
//!!! LDAP_F( void )
//!!! ldap_memfree LDAP_P((
//!!! void* p ));
//!!! LDAP_F( void )
//!!! ldap_memvfree LDAP_P((
//!!! void** v ));
//!!! LDAP_F( char * )
//!!! ldap_strdup LDAP_P((
//!!! LDAP_CONST char * ));
//!!! LDAP_F( void )
//!!! ldap_mods_free LDAP_P((
//!!! LDAPMod **mods,
//!!! int freemods ));
//!!! #if LDAP_DEPRECATED
//
// in sort.c (deprecated, use custom code instead)//!!! typedef int (LDAP_SORT_AD_CMP_PROC) LDAP_P(( // deprecated
//!!! LDAP_CONST char *left,
//!!! LDAP_CONST char *right ));
//!!! typedef int (LDAP_SORT_AV_CMP_PROC) LDAP_P(( // deprecated
//!!! LDAP_CONST void *left,
//!!! LDAP_CONST void *right ));
//!!! LDAP_F( int ) // deprecated
//!!! ldap_sort_entries LDAP_P(( LDAP *ld,
//!!! LDAPMessage **chain,
//!!! LDAP_CONST char *attr,
//!!! LDAP_SORT_AD_CMP_PROC *cmp ));
//!!! LDAP_F( int ) // deprecated
//!!! ldap_sort_values LDAP_P((
//!!! LDAP *ld,
//!!! char **vals,
//!!! LDAP_SORT_AV_CMP_PROC *cmp ));
//!!! LDAP_F( int ) // deprecated
//!!! ldap_sort_strcasecmp LDAP_P((
//!!! LDAP_CONST void *a,
//!!! LDAP_CONST void *b ));
//!!! #endif
//
// in url.c//!!! LDAP_F( int )
//!!! ldap_is_ldap_url LDAP_P((
//!!! LDAP_CONST char *url ));
//!!! LDAP_F( int )
//!!! ldap_is_ldaps_url LDAP_P((
//!!! LDAP_CONST char *url ));
//!!! LDAP_F( int )
//!!! ldap_is_ldapi_url LDAP_P((
//!!! LDAP_CONST char *url ));
//!!! LDAP_F( int )
//!!! ldap_url_parse LDAP_P((
//!!! LDAP_CONST char *url,
//!!! LDAPURLDesc **ludpp ));
//!!! LDAP_F( char * )
//!!! ldap_url_desc2str LDAP_P((
//!!! LDAPURLDesc *ludp ));
//!!! LDAP_F( void )
//!!! ldap_free_urldesc LDAP_P((
//!!! LDAPURLDesc *ludp ));
//
// LDAP Cancel Extended Operation
// in cancel.cconst LDAP_API_FEATURE_CANCEL = 1000
//!!! LDAP_F( int )
//!!! ldap_cancel LDAP_P(( LDAP *ld,
//!!! int cancelid,
//!!! LDAPControl **sctrls,
//!!! LDAPControl **cctrls,
//!!! int *msgidp ));
//!!! LDAP_F( int )
//!!! ldap_cancel_s LDAP_P(( LDAP *ld,
//!!! int cancelid,
//!!! LDAPControl **sctrl,
//!!! LDAPControl **cctrl ));
//
// LDAP Turn Extended Operation
// in turn.cconst LDAP_API_FEATURE_TURN = 1000
//!!! LDAP_F( int )
//!!! ldap_turn LDAP_P(( LDAP *ld,
//!!! int mutual,
//!!! LDAP_CONST char* identifier,
//!!! LDAPControl **sctrls,
//!!! LDAPControl **cctrls,
//!!! int *msgidp ));
//!!! LDAP_F( int )
//!!! ldap_turn_s LDAP_P(( LDAP *ld,
//!!! int mutual,
//!!! LDAP_CONST char* identifier,
//!!! LDAPControl **sctrl,
//!!! LDAPControl **cctrl ));
//
// LDAP Paged Results
// in pagectrl.cconst LDAP_API_FEATURE_PAGED_RESULTS = 2000
//!!! LDAP_F( int )
//!!! ldap_create_page_control_value LDAP_P((
//!!! LDAP *ld,
//!!! ber_int_t pagesize,
//!!! struct berval *cookie,
//!!! struct berval *value ));
//!!! LDAP_F( int )
//!!! ldap_create_page_control LDAP_P((
//!!! LDAP *ld,
//!!! ber_int_t pagesize,
//!!! struct berval *cookie,
//!!! int iscritical,
//!!! LDAPControl **ctrlp ));
//!!! #if LDAP_DEPRECATED
//!!! LDAP_F( int )
//!!! ldap_parse_page_control LDAP_P((
// deprecated, use ldap_parse_pageresponse_control
//!!! LDAP *ld,
//!!! LDAPControl **ctrls,
//!!! ber_int_t *count,
//!!! struct berval **cookie ));
//!!! #endif
//!!! LDAP_F( int )
//!!! ldap_parse_pageresponse_control LDAP_P((
//!!! LDAP *ld,
//!!! LDAPControl *ctrl,
//!!! ber_int_t *count,
//!!! struct berval *cookie ));
//
// LDAP Server Side Sort
// in sortctrl.cconst LDAP_API_FEATURE_SERVER_SIDE_SORT = 2000
// structure for a sort-key
//!!! typedef struct ldapsortkey {
//!!! char *attributeType;
//!!! char *orderingRule;
//!!! int reverseOrder;
//!!! } LDAPSortKey;
//!!! LDAP_F( int )
//!!! ldap_create_sort_keylist LDAP_P((
//!!! LDAPSortKey ***sortKeyList,
//!!! char *keyString ));
//!!! LDAP_F( void )
//!!! ldap_free_sort_keylist LDAP_P((
//!!! LDAPSortKey **sortkeylist ));
//!!! LDAP_F( int )
//!!! ldap_create_sort_control_value LDAP_P((
//!!! LDAP *ld,
//!!! LDAPSortKey **keyList,
//!!! struct berval *value ));
//!!! LDAP_F( int )
//!!! ldap_create_sort_control LDAP_P((
//!!! LDAP *ld,
//!!! LDAPSortKey **keyList,
//!!! int iscritical,
//!!! LDAPControl **ctrlp ));
//!!! LDAP_F( int )
//!!! ldap_parse_sortresponse_control LDAP_P((
//!!! LDAP *ld,
//!!! LDAPControl *ctrl,
//!!! ber_int_t *result,
//!!! char **attribute ));
//
// LDAP Virtual List View
// in vlvctrl.cconst LDAP_API_FEATURE_VIRTUAL_LIST_VIEW = 2000
// structure for virtual list
//!!! typedef struct ldapvlvinfo {
//!!! ber_int_t ldvlv_version;
//!!! ber_int_t ldvlv_before_count;
//!!! ber_int_t ldvlv_after_count;
//!!! ber_int_t ldvlv_offset;
//!!! ber_int_t ldvlv_count;
//!!! struct berval * ldvlv_attrvalue;
//!!! struct berval * ldvlv_context;
//!!! void * ldvlv_extradata;
//!!! } LDAPVLVInfo;
//!!! LDAP_F( int )
//!!! ldap_create_vlv_control_value LDAP_P((
//!!! LDAP *ld,
//!!! LDAPVLVInfo *ldvlistp,
//!!! struct berval *value));
//!!! LDAP_F( int )
//!!! ldap_create_vlv_control LDAP_P((
//!!! LDAP *ld,
//!!! LDAPVLVInfo *ldvlistp,
//!!! LDAPControl **ctrlp ));
//!!! LDAP_F( int )
//!!! ldap_parse_vlvresponse_control LDAP_P((
//!!! LDAP *ld,
//!!! LDAPControl *ctrls,
//!!! ber_int_t *target_posp,
//!!! ber_int_t *list_countp,
//!!! struct berval **contextp,
//!!! int *errcodep ));
//
// LDAP Who Am I?
// in whoami.cconst LDAP_API_FEATURE_WHOAMI = 1000
//!!! LDAP_F( int )
//!!! ldap_parse_whoami LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *res,
//!!! struct berval **authzid ));
//!!! LDAP_F( int )
//!!! ldap_whoami LDAP_P(( LDAP *ld,
//!!! LDAPControl **sctrls,
//!!! LDAPControl **cctrls,
//!!! int *msgidp ));
//!!! LDAP_F( int )
//!!! ldap_whoami_s LDAP_P((
//!!! LDAP *ld,
//!!! struct berval **authzid,
//!!! LDAPControl **sctrls,
//!!! LDAPControl **cctrls ));
//
// LDAP Password Modify
// in passwd.cconst LDAP_API_FEATURE_PASSWD_MODIFY = 1000
//!!! LDAP_F( int )
//!!! ldap_parse_passwd LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *res,
//!!! struct berval *newpasswd ));
//!!! LDAP_F( int )
//!!! ldap_passwd LDAP_P(( LDAP *ld,
//!!! struct berval *user,
//!!! struct berval *oldpw,
//!!! struct berval *newpw,
//!!! LDAPControl **sctrls,
//!!! LDAPControl **cctrls,
//!!! int *msgidp ));
//!!! LDAP_F( int )
//!!! ldap_passwd_s LDAP_P((
//!!! LDAP *ld,
//!!! struct berval *user,
//!!! struct berval *oldpw,
//!!! struct berval *newpw,
//!!! struct berval *newpasswd,
//!!! LDAPControl **sctrls,
//!!! LDAPControl **cctrls ));
//!!! #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
//
// LDAP Password Policy controls
// in ppolicy.cconst LDAP_API_FEATURE_PASSWORD_POLICY = 1000
//!!! typedef enum passpolicyerror_enum {
//!!! PP_passwordExpired = 0,
//!!! PP_accountLocked = 1,
//!!! PP_changeAfterReset = 2,
//!!! PP_passwordModNotAllowed = 3,
//!!! PP_mustSupplyOldPassword = 4,
//!!! PP_insufficientPasswordQuality = 5,
//!!! PP_passwordTooShort = 6,
//!!! PP_passwordTooYoung = 7,
//!!! PP_passwordInHistory = 8,
//!!! PP_noError = 65535
//!!! } LDAPPasswordPolicyError;
//!!! LDAP_F( int )
//!!! ldap_create_passwordpolicy_control LDAP_P((
//!!! LDAP *ld,
//!!! LDAPControl **ctrlp ));
//!!! LDAP_F( int )
//!!! ldap_parse_passwordpolicy_control LDAP_P((
//!!! LDAP *ld,
//!!! LDAPControl *ctrl,
//!!! ber_int_t *expirep,
//!!! ber_int_t *gracep,
//!!! LDAPPasswordPolicyError *errorp ));
//!!! LDAP_F( const char * )
//!!! ldap_passwordpolicy_err2txt LDAP_P(( LDAPPasswordPolicyError ));
//!!! #endif // LDAP_CONTROL_PASSWORDPOLICYREQUEST
//
// LDAP Dynamic Directory Services Refresh -- RFC 2589
// in dds.cconst LDAP_API_FEATURE_REFRESH = 1000
//!!! LDAP_F( int )
//!!! ldap_parse_refresh LDAP_P((
//!!! LDAP *ld,
//!!! LDAPMessage *res,
//!!! ber_int_t *newttl ));
//!!! LDAP_F( int )
//!!! ldap_refresh LDAP_P(( LDAP *ld,
//!!! struct berval *dn,
//!!! ber_int_t ttl,
//!!! LDAPControl **sctrls,
//!!! LDAPControl **cctrls,
//!!! int *msgidp ));
//!!! LDAP_F( int )
//!!! ldap_refresh_s LDAP_P((
//!!! LDAP *ld,
//!!! struct berval *dn,
//!!! ber_int_t ttl,
//!!! ber_int_t *newttl,
//!!! LDAPControl **sctrls,
//!!! LDAPControl **cctrls ));
//
// LDAP Transactions//!!! #ifdef LDAP_X_TXN
//!!! LDAP_F( int )
//!!! ldap_txn_start LDAP_P(( LDAP *ld,
//!!! LDAPControl **sctrls,
//!!! LDAPControl **cctrls,
//!!! int *msgidp ));
//!!! LDAP_F( int )
//!!! ldap_txn_start_s LDAP_P(( LDAP *ld,
//!!! LDAPControl **sctrl,
//!!! LDAPControl **cctrl,
//!!! struct berval **rettxnid ));
//!!! LDAP_F( int )
//!!! ldap_txn_end LDAP_P(( LDAP *ld,
//!!! int commit,
//!!! struct berval *txnid,
//!!! LDAPControl **sctrls,
//!!! LDAPControl **cctrls,
//!!! int *msgidp ));
//!!! LDAP_F( int )
//!!! ldap_txn_end_s LDAP_P(( LDAP *ld,
//!!! int commit,
//!!! struct berval *txnid,
//!!! LDAPControl **sctrl,
//!!! LDAPControl **cctrl,
//!!! int *retidp ));
//!!! #endif
//
// in ldap_sync.c
//
// initialize the persistent search structure//!!! LDAP_F( ldap_sync_t * )
//!!! ldap_sync_initialize LDAP_P((
//!!! ldap_sync_t *ls ));
//
// destroy the persistent search structure//!!! LDAP_F( void )
//!!! ldap_sync_destroy LDAP_P((
//!!! ldap_sync_t *ls,
//!!! int freeit ));
//
// initialize a refreshOnly sync//!!! LDAP_F( int )
//!!! ldap_sync_init LDAP_P((
//!!! ldap_sync_t *ls,
//!!! int mode ));
//
// initialize a refreshOnly sync//!!! LDAP_F( int )
//!!! ldap_sync_init_refresh_only LDAP_P((
//!!! ldap_sync_t *ls ));
//
// initialize a refreshAndPersist sync//!!! LDAP_F( int )
//!!! ldap_sync_init_refresh_and_persist LDAP_P((
//!!! ldap_sync_t *ls ));
//
// poll for new responses//!!! LDAP_F( int )
//!!! ldap_sync_poll LDAP_P((
//!!! ldap_sync_t *ls ));
//!!! #ifdef LDAP_CONTROL_X_SESSION_TRACKING
//
// in stctrl.c//!!! LDAP_F( int )
//!!! ldap_create_session_tracking_value LDAP_P((
//!!! LDAP *ld,
//!!! char *sessionSourceIp,
//!!! char *sessionSourceName,
//!!! char *formatOID,
//!!! struct berval *sessionTrackingIdentifier,
//!!! struct berval *value ));
//!!! LDAP_F( int )
//!!! ldap_create_session_tracking LDAP_P((
//!!! LDAP *ld,
//!!! char *sessionSourceIp,
//!!! char *sessionSourceName,
//!!! char *formatOID,
//!!! struct berval *sessionTrackingIdentifier,
//!!! LDAPControl **ctrlp ));
//!!! LDAP_F( int )
//!!! ldap_parse_session_tracking_control LDAP_P((
//!!! LDAP *ld,
//!!! LDAPControl *ctrl,
//!!! struct berval *ip,
//!!! struct berval *name,
//!!! struct berval *oid,
//!!! struct berval *id ));
//!!! #endif // LDAP_CONTROL_X_SESSION_TRACKING
//
// in assertion.c//!!! LDAP_F (int)
//!!! ldap_create_assertion_control_value LDAP_P((
//!!! LDAP *ld,
//!!! char *assertion,
//!!! struct berval *value ));
//!!! LDAP_F( int )
//!!! ldap_create_assertion_control LDAP_P((
//!!! LDAP *ld,
//!!! char *filter,
//!!! int iscritical,
//!!! LDAPControl **ctrlp ));
//
// in deref.c
//!!! typedef struct LDAPDerefSpec {
//!!! char *derefAttr;
//!!! char **attributes;
//!!! } LDAPDerefSpec;
//!!! typedef struct LDAPDerefVal {
//!!! char *type;
//!!! BerVarray vals;
//!!! struct LDAPDerefVal *next;
//!!! } LDAPDerefVal;
//!!! typedef struct LDAPDerefRes {
//!!! char *derefAttr;
//!!! struct berval derefVal;
//!!! LDAPDerefVal *attrVals;
//!!! struct LDAPDerefRes *next;
//!!! } LDAPDerefRes;
//!!! LDAP_F( int )
//!!! ldap_create_deref_control_value LDAP_P((
//!!! LDAP *ld,
//!!! LDAPDerefSpec *ds,
//!!! struct berval *value ));
//!!! LDAP_F( int )
//!!! ldap_create_deref_control LDAP_P((
//!!! LDAP *ld,
//!!! LDAPDerefSpec *ds,
//!!! int iscritical,
//!!! LDAPControl **ctrlp ));
//!!! LDAP_F( void )
//!!! ldap_derefresponse_free LDAP_P((
//!!! LDAPDerefRes *dr ));
//!!! LDAP_F( int )
//!!! ldap_parse_derefresponse_control LDAP_P((
//!!! LDAP *ld,
//!!! LDAPControl *ctrl,
//!!! LDAPDerefRes **drp ));
//!!! LDAP_F( int )
//!!! ldap_parse_deref_control LDAP_P((
//!!! LDAP *ld,
//!!! LDAPControl **ctrls,
//!!! LDAPDerefRes **drp ));
//!!! LDAP_END_DECL
//!!! #endif // _LDAP_H
golang-openldap-0.2/_examples/ 0000775 0000000 0000000 00000000000 11766376717 0016424 5 ustar 00root root 0000000 0000000 golang-openldap-0.2/_examples/ldapsearch.go 0000664 0000000 0000000 00000006104 11766376717 0021062 0 ustar 00root root 0000000 0000000 package main
/*
* Author : Marc Quinton / 2012.
*
* ldapsearch command mimics openldap/seach command. Supported options :
* - host : ldap[s]://hostname:port/ format,
* - user,
* - password,
* - base
*
* arguments : filter [attributes]
* - filter is an LDAP filter (ex: objectClass=*, cn=*admin*", ...
* - attributes is an LDAP attribute list ; can be empty. ex: cn, sn, givenName, mail, ...
*
*/
import (
"fmt"
"os"
"errors"
"flag"
"github.com/mqu/openldap"
)
type LdapSearchOptions struct {
host string
user string
passwd string
base string
filter string
attributes []string
scope int
}
type LdapSearchApp struct {
ldap *openldap.Ldap
opts *LdapSearchOptions
}
func NewLdapSearchApp() *LdapSearchApp{
app := new(LdapSearchApp)
return app
}
// Show ldapsearch app usage
func (self *LdapSearchApp) Usage(){
fmt.Printf("usage: %s filter [attribute list]\n", os.Args[0])
flag.PrintDefaults()
}
// Parse ldapsearch app options using flag package.
func (self *LdapSearchApp) ParseOpts() (*LdapSearchOptions, error){
var opts LdapSearchOptions
flag.StringVar(&opts.host, "host", "ldap://localhost:389/", "ldap server URL format : ldap[s]://hostname:port/")
flag.StringVar(&opts.user, "user", "" , "user for authentification")
flag.StringVar(&opts.passwd, "passwd", "" , "password for authentification")
flag.StringVar(&opts.base, "base", "" , "base DN for search")
flag.Parse()
if flag.NArg() == 0 {
self.Usage()
return nil, errors.New(fmt.Sprintf("ParseOpts() error ; see usage for more information"))
}
opts.filter = flag.Arg(0)
if len(flag.Args()) == 1 {
opts.attributes = []string{}
} else {
opts.attributes = flag.Args()[1:]
}
return &opts, nil
}
// Connect and Bind to LDAP server using self.opts
func (self *LdapSearchApp) Connect() (error){
var err error
self.ldap, err = openldap.Initialize(self.opts.host)
if err != nil {
return err
}
//FIXME: should be an external option
self.ldap.SetOption(openldap.LDAP_OPT_PROTOCOL_VERSION, openldap.LDAP_VERSION3)
err = self.ldap.Bind(self.opts.user, self.opts.passwd)
if err != nil {
return err
}
return nil
}
// Close() disconnect application from Ldap server
func (self *LdapSearchApp) Close() (error){
return self.ldap.Close()
}
// Search using filter and returning attributes list
func (self *LdapSearchApp) Search() (*openldap.LdapSearchResult, error){
//FIXME: should be an external option
scope := openldap.LDAP_SCOPE_SUBTREE
return self.ldap.SearchAll(
self.opts.base,
scope,
self.opts.filter,
self.opts.attributes)
}
// Print search result
func (self *LdapSearchApp) Print(res *openldap.LdapSearchResult) (error){
fmt.Println(res)
return nil
}
func main() {
var err error
app := NewLdapSearchApp()
app.opts, err = app.ParseOpts()
if err != nil {
fmt.Println(err)
return
}
err = app.Connect()
if err != nil {
fmt.Println(err)
return
}
result, err := app.Search()
if(err != nil) {
fmt.Println("search error:", err)
return
}
app.Print(result)
app.Close()
}
golang-openldap-0.2/_examples/test-openldap.go 0000664 0000000 0000000 00000004161 11766376717 0021534 0 ustar 00root root 0000000 0000000 package main
import (
"fmt"
"github.com/mqu/openldap"
)
/*
*
* openldap example program :
*
* - 1 :
*
* - specify URL for LDAP connexion with user and passwd
* - ldap and ldaps is supported,
* - anonymous connexion is done with an empty user string
* - base (DN) is needed for many LDAP server (it depends on LDAP data design)
*
* - 2 :
*
* - you can set some LDAP options.
* - authentification with Bind()
*
* - 3 : setup LDAP query search.
* - 4 : print search results.
*
*/
func main() {
var user, passwd, url, base string
// (1) - connexion options
url = "ldap://some.host:389/"
// url = "ldaps://some.host:636/"
user = "..."
passwd = "..."
base = ""
ldap, err := openldap.Initialize(url)
if err != nil {
fmt.Printf("LDAP::Initialize() : connexion error\n")
return
}
// (2.1) - options
ldap.SetOption(openldap.LDAP_OPT_PROTOCOL_VERSION, openldap.LDAP_VERSION3)
// (2.2) - authentification (Bind)
err = ldap.Bind(user, passwd)
if err != nil {
fmt.Printf("LDAP::Bind() : bind error\n")
fmt.Println(err)
return
}
defer ldap.Close()
// (3) : search method
// -------------------------------------- Ldap::SearchAll() --------------------------------------
scope := openldap.LDAP_SCOPE_SUBTREE // LDAP_SCOPE_BASE, LDAP_SCOPE_ONELEVEL, LDAP_SCOPE_SUBTREE
filter := "cn=*admin*"
attributes := []string{"cn", "sn", "givenname", "mail"} // leave empty for all attributes
// SearchAll(base string, scope int, filter string, attributes []string) (*LdapSearchResult, error)
result, err := ldap.SearchAll(base, scope, filter, attributes)
if err != nil {
fmt.Println(err)
return
}
// (4) - print LdapSearchResult(s)
fmt.Printf("# num results : %d\n", result.Count())
fmt.Printf("# search : %s\n", result.Filter())
fmt.Printf("# base : %s\n", result.Base())
fmt.Printf("# attributes : [%s]\n", strings.Join(result.Attributes(), ", "))
for _, entry := range result.Entries() {
fmt.Printf("dn=%s\n", entry.Dn())
for _, attr := range entry.Attributes() {
fmt.Printf("%s=[%s]\n", attr.Name(), strings.Join(attr.Values(), ", "))
}
fmt.Printf("\n")
}
}
golang-openldap-0.2/add-modify-delete.go 0000664 0000000 0000000 00000013756 11766376717 0020267 0 ustar 00root root 0000000 0000000 package openldap
/* #include
#include
#include
// goc can not use union on structs ; so create a new type with same attributes and size
// fixme : support binary mods (mod_bvalues)
typedef struct ldapmod_str {
int mod_op;
char *mod_type;
char **mod_vals;
} LDAPModStr;
int _ldap_add(LDAP *ld, char* dn, LDAPModStr **attrs){
//API: int ldap_add_ext_s(LDAP *ld, char *dn, LDAPMod **attrs, LDAPControl *sctrls, LDAPControl *cctrls );
// nota : cast (LDAPMod **) is possible because structs have same size
return ldap_add_ext_s(ld, dn, (LDAPMod **)attrs, NULL, NULL);
}
int _ldap_modify(LDAP *ld, char* dn, LDAPModStr **mods ){
// nota : cast (LDAPMod **) is possible because structs have same size
return ldap_modify_ext_s( ld, dn, (LDAPMod **)mods, NULL, NULL);
}
int _ldap_rename (LDAP *ld, char *dn, char *newrdn, char *newSuperior, int deleteoldrdn){
//API: int ldap_rename_s( ld, dn, newrdn, newparent, deleteoldrdn, sctrls[], cctrls[])
return ldap_rename_s(ld, dn, newrdn, newSuperior, deleteoldrdn, NULL, NULL);
}
void _ldap_mods_free (LDAPModStr **mods, int freemods){
//API: void ldap_mods_free(LDAPMod **mods, int freemods);
return ldap_mods_free((LDAPMod **)mods, freemods);
}
*/
// #cgo CFLAGS: -DLDAP_DEPRECATED=1
// #cgo linux CFLAGS: -DLINUX=1
// #cgo LDFLAGS: -lldap -llber
import "C"
import (
"errors"
"unsafe"
"fmt"
)
func (self *Ldap) doModify(dn string, attrs map[string][]string, changeType int, full_add bool) (int){
_dn := C.CString(dn)
defer C.free(unsafe.Pointer(_dn))
mods := make([]*C.LDAPModStr, len(attrs)+1)
// mods[len] = nil by default
count:= 0
for key, values := range attrs {
// transform []string to C.char** null terminated array (attributes argument)
_values := make([]*C.char, len(values)+1) // default set to nil (NULL in C)
for i, value := range values {
_values[i] = C.CString(value)
defer C.free(unsafe.Pointer(_values[i]))
}
var mod C.LDAPModStr
mod.mod_op = C.int(changeType)
mod.mod_type = C.CString(key)
mod.mod_vals = &_values[0]
defer C.free(unsafe.Pointer(mod.mod_type))
mods[count] = &mod
count++
}
var rv int
if full_add {
// API: int ldap_add (LDAP *ld, LDAP_CONST char *dn, LDAPMod **mods )
rv = int(C._ldap_add(self.conn, _dn, &mods[0]))
} else{
// API: int ldap_modify (LDAP *ld, LDAP_CONST char *dn, LDAPMod **mods )
rv = int(C._ldap_modify(self.conn, _dn, &mods[0]))
}
// FIXME: need to call ldap_mods_free(&mods) some where.
// C._ldap_mods_free(&mods[0], 1) // not OK.
return rv
}
func (self *Ldap) Modify(dn string, attrs map[string][]string) (error){
changeType := C.LDAP_MOD_REPLACE
full_add := false
rv := self.doModify(dn, attrs, changeType, full_add)
if rv != LDAP_OPT_SUCCESS {
return errors.New(fmt.Sprintf("LDAP::Modify() error : %d (%s)", rv, ErrorToString(rv)))
}
return nil
}
func (self *Ldap) ModifyDel(dn string, attrs map[string][]string) (error){
changeType := C.LDAP_MOD_DELETE
full_add := false
rv := self.doModify(dn, attrs, changeType, full_add)
if rv != LDAP_OPT_SUCCESS {
return errors.New(fmt.Sprintf("LDAP::ModifyDel() error : %d (%s)", rv, ErrorToString(rv)))
}
return nil
}
func (self *Ldap) ModifyAdd(dn string, attrs map[string][]string) (error){
changeType := C.LDAP_MOD_ADD
full_add := false
rv := self.doModify(dn, attrs, changeType, full_add)
if rv != LDAP_OPT_SUCCESS {
return errors.New(fmt.Sprintf("LDAP::ModifyAdd() error : %d (%s)", rv, ErrorToString(rv)))
}
return nil
}
func (self *Ldap) Add(dn string, attrs map[string][]string) (error){
changeType := C.LDAP_MOD_ADD
full_add := true
rv := self.doModify(dn, attrs, changeType, full_add)
if rv != LDAP_OPT_SUCCESS {
return errors.New(fmt.Sprintf("LDAP::Add() error : %d (%s)", rv, ErrorToString(rv)))
}
return nil
}
func (self *Ldap) Delete(dn string) (error){
_dn := C.CString(dn)
defer C.free(unsafe.Pointer(_dn))
// API: int ldap_delete (LDAP *ld, LDAP_CONST char *dn)
rv := C.ldap_delete_s(self.conn, _dn)
if rv != LDAP_OPT_SUCCESS {
return errors.New(fmt.Sprintf("LDAP::Delete() error : %d (%s)", rv, ErrorToString(int(rv))))
}
return nil
}
// Rename() to rename LDAP entries.
//
// These routines are used to perform a LDAP rename operation. The function changes the leaf compo-
// nent of an entry's distinguished name and optionally moves the entry to a new parent container.
// The ldap_rename_s performs a rename operation synchronously. The method takes dn, which points to
// the distinguished name of the entry whose attribute is being compared, newparent,the distinguished
// name of the entry's new parent. If this parameter is NULL, only the RDN is changed. The root DN is
// specified by passing a zero length string, "". deleteoldrdn specifies whether the old RDN should
// be retained or deleted. Zero indicates that the old RDN should be retained. If you choose this
// option, the attribute will contain both names (the old and the new). Non-zero indicates that the
// old RDN should be deleted. serverctrls points to an array of LDAPControl structures that list the
// client controls to use with this extended operation. Use NULL to specify no client controls.
// clientctrls points to an array of LDAPControl structures that list the client controls to use with
// the search.
// FIXME: support NULL and "" values for newSuperior parameter.
//
func (self *Ldap) Rename(dn string, newrdn string, newSuperior string, deleteOld bool) (error){
_dn := C.CString(dn)
defer C.free(unsafe.Pointer(_dn))
_newrdn := C.CString(newrdn)
defer C.free(unsafe.Pointer(_newrdn))
_newSuperior := C.CString(newSuperior)
defer C.free(unsafe.Pointer(_newSuperior))
var _delete C.int = 0
if deleteOld {
_delete = 1
}
// API: int ldap_rename (LDAP *ld, char *newrdn, char *newSuperior, int deleteoldrdn)
rv := C._ldap_rename(self.conn, _dn, _newrdn, _newSuperior, _delete)
if rv != LDAP_OPT_SUCCESS {
return errors.New(fmt.Sprintf("LDAP::Rename() error : %d (%s)", rv, ErrorToString(int(rv))))
}
return nil
}
golang-openldap-0.2/defines.go 0000664 0000000 0000000 00000020750 11766376717 0016417 0 ustar 00root root 0000000 0000000 package openldap
const (
// first version for this GO API binding
OPENLDAP_API_BINDING_VERSION = "0.2"
)
const (
LDAP_VERSION1 = 1
LDAP_VERSION2 = 2
LDAP_VERSION3 = 3
)
const (
LDAP_VERSION_MIN = LDAP_VERSION2
LDAP_VERSION = LDAP_VERSION2
LDAP_VERSION_MAX = LDAP_VERSION3
)
const (
LDAP_API_VERSION = 3001
LDAP_VENDOR_NAME = "OpenLDAP"
)
const (
LDAP_PORT = 389
LDAPS_PORT = 636
)
const (
LDAP_OPT_SUCCESS = 0
LDAP_OPT_ERROR = -1
)
// search scopes
const (
LDAP_SCOPE_BASE = 0x0000
LDAP_SCOPE_ONELEVEL = 0x0001
LDAP_SCOPE_SUBTREE = 0x0002
LDAP_SCOPE_SUBORDINATE = 0x0003 // OpenLDAP extension
LDAP_SCOPE_DEFAULT = -1 // OpenLDAP extension
)
const (
LDAP_SCOPE_BASEOBJECT = LDAP_SCOPE_BASE
LDAP_SCOPE_ONE = LDAP_SCOPE_ONELEVEL
LDAP_SCOPE_SUB = LDAP_SCOPE_SUBTREE
LDAP_SCOPE_CHILDREN = LDAP_SCOPE_SUBORDINATE
)
const (
LDAP_RES_ANY = -1
LDAP_RES_UNSOLICITED = 0
)
//const (
//LDAP_API_FEATURE_THREAD_SAFE = 1
//LDAP_API_FEATURE_SESSION_THREAD_SAFE = 1
//LDAP_API_FEATURE_OPERATION_THREAD_SAFE = 1
//)
const (
LDAP_SUCCESS = 0x00
LDAP_OPERATIONS_ERROR = 0x01
LDAP_PROTOCOL_ERROR = 0x02
LDAP_TIMELIMIT_EXCEEDED = 0x03
LDAP_SIZELIMIT_EXCEEDED = 0x04
LDAP_COMPARE_FALSE = 0x05
LDAP_COMPARE_TRUE = 0x06
LDAP_AUTH_METHOD_NOT_SUPPORTED = 0x07
LDAP_STRONG_AUTH_REQUIRED = 0x08
// Not used in LDAPv3
LDAP_PARTIAL_RESULTS = 0x09
// Next 5 new in LDAPv3
LDAP_REFERRAL = 0x0a
LDAP_ADMINLIMIT_EXCEEDED = 0x0b
LDAP_UNAVAILABLE_CRITICAL_EXTENSION = 0x0c
LDAP_CONFIDENTIALITY_REQUIRED = 0x0d
LDAP_SASL_BIND_INPROGRESS = 0x0e
LDAP_NO_SUCH_ATTRIBUTE = 0x10
LDAP_UNDEFINED_TYPE = 0x11
LDAP_INAPPROPRIATE_MATCHING = 0x12
LDAP_CONSTRAINT_VIOLATION = 0x13
LDAP_TYPE_OR_VALUE_EXISTS = 0x14
LDAP_INVALID_SYNTAX = 0x15
LDAP_NO_SUCH_OBJECT = 0x20 /* 32 */
LDAP_ALIAS_PROBLEM = 0x21
LDAP_INVALID_DN_SYNTAX = 0x22
// Next two not used in LDAPv3
LDAP_IS_LEAF = 0x23
LDAP_ALIAS_DEREF_PROBLEM = 0x24
LDAP_INAPPROPRIATE_AUTH = 0x30 /* 48 */
LDAP_INVALID_CREDENTIALS = 0x31 /* 49 */
LDAP_INSUFFICIENT_ACCESS = 0x32
LDAP_BUSY = 0x33
LDAP_UNAVAILABLE = 0x34
LDAP_UNWILLING_TO_PERFORM = 0x35
LDAP_LOOP_DETECT = 0x36
LDAP_SORT_CONTROL_MISSING = 0x3C /* 60 */
LDAP_INDEX_RANGE_ERROR = 0x3D /* 61 */
LDAP_NAMING_VIOLATION = 0x40
LDAP_OBJECT_CLASS_VIOLATION = 0x41
LDAP_NOT_ALLOWED_ON_NONLEAF = 0x42
LDAP_NOT_ALLOWED_ON_RDN = 0x43
LDAP_ALREADY_EXISTS = 0x44 /* 68 */
LDAP_NO_OBJECT_CLASS_MODS = 0x45
LDAP_RESULTS_TOO_LARGE = 0x46
// Next two for LDAPv3
LDAP_AFFECTS_MULTIPLE_DSAS = 0x47
LDAP_OTHER = 0x50
// Used by some APIs
LDAP_SERVER_DOWN = 0x51
LDAP_LOCAL_ERROR = 0x52
LDAP_ENCODING_ERROR = 0x53
LDAP_DECODING_ERROR = 0x54
LDAP_TIMEOUT = 0x55
LDAP_AUTH_UNKNOWN = 0x56
LDAP_FILTER_ERROR = 0x57 /* 87 */
LDAP_USER_CANCELLED = 0x58
LDAP_PARAM_ERROR = 0x59
LDAP_NO_MEMORY = 0x5a
// Preliminary LDAPv3 codes
LDAP_CONNECT_ERROR = 0x5b
LDAP_NOT_SUPPORTED = 0x5c
LDAP_CONTROL_NOT_FOUND = 0x5d
LDAP_NO_RESULTS_RETURNED = 0x5e
LDAP_MORE_RESULTS_TO_RETURN = 0x5f
LDAP_CLIENT_LOOP = 0x60
LDAP_REFERRAL_LIMIT_EXCEEDED = 0x61
)
const (
LDAP_DEREF_NEVER = 0
LDAP_DEREF_SEARCHING = 1
LDAP_DEREF_FINDING = 2
LDAP_DEREF_ALWAYS = 3
)
const (
LDAP_NO_LIMIT = 0
)
const (
LDAP_MSG_ONE = 0
LDAP_MSG_ALL = 1
LDAP_MSG_RECEIVED = 2
)
// LDAP_OPTions
// 0x0000 - 0x0fff reserved for api options
// 0x1000 - 0x3fff reserved for api extended options
// 0x4000 - 0x7fff reserved for private and experimental options
const (
LDAP_OPT_API_INFO = 0x0000
LDAP_OPT_DESC = 0x0001 // historic
LDAP_OPT_DEREF = 0x0002
LDAP_OPT_SIZELIMIT = 0x0003
LDAP_OPT_TIMELIMIT = 0x0004
// 0x05 - 0x07 not defined
LDAP_OPT_REFERRALS = 0x0008
LDAP_OPT_RESTART = 0x0009
// 0x0a - 0x10 not defined
LDAP_OPT_PROTOCOL_VERSION = 0x0011
LDAP_OPT_SERVER_CONTROLS = 0x0012
LDAP_OPT_CLIENT_CONTROLS = 0x0013
// 0x14 not defined
LDAP_OPT_API_FEATURE_INFO = 0x0015
// 0x16 - 0x2f not defined
LDAP_OPT_HOST_NAME = 0x0030
LDAP_OPT_RESULT_CODE = 0x0031
LDAP_OPT_ERROR_NUMBER = LDAP_OPT_RESULT_CODE
LDAP_OPT_DIAGNOSTIC_MESSAGE = 0x0032
LDAP_OPT_ERROR_STRING = LDAP_OPT_DIAGNOSTIC_MESSAGE
LDAP_OPT_MATCHED_DN = 0x0033
// 0x0034 - 0x3fff not defined
// 0x0091 used by Microsoft for LDAP_OPT_AUTO_RECONNECT
LDAP_OPT_SSPI_FLAGS = 0x0092
// 0x0093 used by Microsoft for LDAP_OPT_SSL_INFO
// 0x0094 used by Microsoft for LDAP_OPT_REF_DEREF_CONN_PER_MSG
LDAP_OPT_SIGN = 0x0095
LDAP_OPT_ENCRYPT = 0x0096
LDAP_OPT_SASL_METHOD = 0x0097
// 0x0098 used by Microsoft for LDAP_OPT_AREC_EXCLUSIVE
LDAP_OPT_SECURITY_CONTEXT = 0x0099
// 0x009A used by Microsoft for LDAP_OPT_ROOTDSE_CACHE
// 0x009B - 0x3fff not defined
)
// API Extensions
const LDAP_OPT_API_EXTENSION_BASE = 0x4000 // API extensions
// private and experimental options
// OpenLDAP specific options
const (
LDAP_OPT_DEBUG_LEVEL = 0x5001 // debug level
LDAP_OPT_TIMEOUT = 0x5002 // default timeout
LDAP_OPT_REFHOPLIMIT = 0x5003 // ref hop limit
LDAP_OPT_NETWORK_TIMEOUT = 0x5005 // socket level timeout
LDAP_OPT_URI = 0x5006
LDAP_OPT_REFERRAL_URLS = 0x5007 // Referral URLs
LDAP_OPT_SOCKBUF = 0x5008 // sockbuf
LDAP_OPT_DEFBASE = 0x5009 // searchbase
LDAP_OPT_CONNECT_ASYNC = 0x5010 // create connections asynchronously
LDAP_OPT_CONNECT_CB = 0x5011 // connection callbacks
LDAP_OPT_SESSION_REFCNT = 0x5012 // session reference count
)
// OpenLDAP TLS options
const (
LDAP_OPT_X_TLS = 0x6000
LDAP_OPT_X_TLS_CTX = 0x6001 // OpenSSL CTX*
LDAP_OPT_X_TLS_CACERTFILE = 0x6002
LDAP_OPT_X_TLS_CACERTDIR = 0x6003
LDAP_OPT_X_TLS_CERTFILE = 0x6004
LDAP_OPT_X_TLS_KEYFILE = 0x6005
LDAP_OPT_X_TLS_REQUIRE_CERT = 0x6006
LDAP_OPT_X_TLS_PROTOCOL_MIN = 0x6007
LDAP_OPT_X_TLS_CIPHER_SUITE = 0x6008
LDAP_OPT_X_TLS_RANDOM_FILE = 0x6009
LDAP_OPT_X_TLS_SSL_CTX = 0x600a // OpenSSL SSL*
LDAP_OPT_X_TLS_CRLCHECK = 0x600b
LDAP_OPT_X_TLS_CONNECT_CB = 0x600c
LDAP_OPT_X_TLS_CONNECT_ARG = 0x600d
LDAP_OPT_X_TLS_DHFILE = 0x600e
LDAP_OPT_X_TLS_NEWCTX = 0x600f
LDAP_OPT_X_TLS_CRLFILE = 0x6010 // GNUtls only
LDAP_OPT_X_TLS_PACKAGE = 0x6011
)
const (
LDAP_OPT_X_TLS_NEVER = 0
LDAP_OPT_X_TLS_HARD = 1
LDAP_OPT_X_TLS_DEMAND = 2
LDAP_OPT_X_TLS_ALLOW = 3
LDAP_OPT_X_TLS_TRY = 4
)
const (
LDAP_OPT_X_TLS_CRL_NONE = 0
LDAP_OPT_X_TLS_CRL_PEER = 1
LDAP_OPT_X_TLS_CRL_ALL = 2
)
// for LDAP_OPT_X_TLS_PROTOCOL_MIN
//!!! const (
//!!! LDAP_OPT_X_TLS_PROTOCOL(maj,min) = (((maj) << 8) + (min))
//!!! LDAP_OPT_X_TLS_PROTOCOL_SSL2 = (2 << 8)
//!!! LDAP_OPT_X_TLS_PROTOCOL_SSL3 = (3 << 8)
//!!! LDAP_OPT_X_TLS_PROTOCOL_TLS1_0 = ((3 << 8) + 1)
//!!! LDAP_OPT_X_TLS_PROTOCOL_TLS1_1 = ((3 << 8) + 2)
//!!! LDAP_OPT_X_TLS_PROTOCOL_TLS1_2 = ((3 << 8) + 3)
//!!! )
// OpenLDAP SASL options
const (
LDAP_OPT_X_SASL_MECH = 0x6100
LDAP_OPT_X_SASL_REALM = 0x6101
LDAP_OPT_X_SASL_AUTHCID = 0x6102
LDAP_OPT_X_SASL_AUTHZID = 0x6103
LDAP_OPT_X_SASL_SSF = 0x6104 // read-only
LDAP_OPT_X_SASL_SSF_EXTERNAL = 0x6105 // write-only
LDAP_OPT_X_SASL_SECPROPS = 0x6106 // write-only
LDAP_OPT_X_SASL_SSF_MIN = 0x6107
LDAP_OPT_X_SASL_SSF_MAX = 0x6108
LDAP_OPT_X_SASL_MAXBUFSIZE = 0x6109
LDAP_OPT_X_SASL_MECHLIST = 0x610a // read-only
LDAP_OPT_X_SASL_NOCANON = 0x610b
LDAP_OPT_X_SASL_USERNAME = 0x610c // read-only
LDAP_OPT_X_SASL_GSS_CREDS = 0x610d
)
// OpenLDAP GSSAPI options
const (
LDAP_OPT_X_GSSAPI_DO_NOT_FREE_CONTEXT = 0x6200
LDAP_OPT_X_GSSAPI_ALLOW_REMOTE_PRINCIPAL = 0x6201
)
//
// OpenLDAP per connection tcp-keepalive settings
// (Linux only, ignored where unsupported)
const (
LDAP_OPT_X_KEEPALIVE_IDLE = 0x6300
LDAP_OPT_X_KEEPALIVE_PROBES = 0x6301
LDAP_OPT_X_KEEPALIVE_INTERVAL = 0x6302
)
/* authentication methods available */
const (
LDAP_AUTH_NONE = 0x00 // no authentication
LDAP_AUTH_SIMPLE = 0x80 // context specific + primitive
LDAP_AUTH_SASL = 0xa3 // context specific + constructed
LDAP_AUTH_KRBV4 = 0xff // means do both of the following
LDAP_AUTH_KRBV41 = 0x81 // context specific + primitive
LDAP_AUTH_KRBV42 = 0x82 // context specific + primitive
)
golang-openldap-0.2/openldap.go 0000664 0000000 0000000 00000022020 11766376717 0016574 0 ustar 00root root 0000000 0000000 /*
* Openldap (2.4.30) binding in GO
*
*
* link to ldap or ldap_r (for thread-safe binding)
*
*/
package openldap
/*
#include
#include
static inline char* to_charptr(const void* s) { return (char*)s; }
*/
// #cgo CFLAGS: -DLDAP_DEPRECATED=1
// #cgo linux CFLAGS: -DLINUX=1
// #cgo LDFLAGS: -lldap -llber
import "C"
import (
"errors"
"fmt"
"unsafe"
"strings"
"strconv"
)
/* Intialize() open an LDAP connexion ; supported url formats :
*
* ldap://host:389/
* ldaps://secure-host:636/
*
* return values :
* - on success : LDAP object, nil
* - on error : nil and error with error description.
*/
func Initialize(url string) (*Ldap, error) {
_url := C.CString(url)
defer C.free(unsafe.Pointer(_url))
var ldap *C.LDAP
// API: int ldap_initialize (LDAP **ldp, LDAP_CONST char *url )
rv := C.ldap_initialize(&ldap, _url)
if rv != 0 {
err := errors.New(fmt.Sprintf("LDAP::Initialize() error (%d) : %s", rv, ErrorToString(int(rv))))
return nil, err
}
return &Ldap{ldap}, nil
}
/*
* Bind() is used for LDAP authentifications
*
* if who is empty this is an anonymous bind
* else this is an authentificated bind
*
* return value :
* - nil on succes,
* - error with error description on error.
*
*/
func (self *Ldap) Bind(who, cred string) error {
var rv int
authmethod := C.int(LDAP_AUTH_SIMPLE)
// DEPRECATED
// API: int ldap_bind_s (LDAP *ld, LDAP_CONST char *who, LDAP_CONST char *cred, int authmethod );
if who == "" {
_who := C.to_charptr(unsafe.Pointer(nil))
_cred := C.to_charptr(unsafe.Pointer(nil))
rv = int(C.ldap_bind_s(self.conn, _who, _cred, authmethod))
} else {
_who := C.CString(who)
_cred := C.CString(cred)
defer C.free(unsafe.Pointer(_who))
rv = int(C.ldap_bind_s(self.conn, _who, _cred, authmethod))
}
if rv == LDAP_OPT_SUCCESS {
return nil
}
self.conn = nil
return errors.New(fmt.Sprintf("LDAP::Bind() error (%d) : %s", rv, ErrorToString(rv)))
}
/*
* close LDAP connexion
*
* return value :
* - nil on succes,
* - error with error description on error.
*
*/
func (self *Ldap) Close() error {
// DEPRECATED
// API: int ldap_unbind(LDAP *ld)
rv := C.ldap_unbind(self.conn)
if rv == LDAP_OPT_SUCCESS {
return nil
}
self.conn = nil
return errors.New(fmt.Sprintf("LDAP::Close() error (%d) : %s", int(rv), ErrorToString(int(rv))))
}
/*
* Unbind() close LDAP connexion
*
* an alias to Ldap::Close()
*
*/
func (self *Ldap) Unbind() error {
return self.Close()
}
/* Search() is used to search LDAP server
- base is where search is starting
- scope allows local or deep search. Supported values :
- LDAP_SCOPE_BASE
- LDAP_SCOPE_ONELEVEL
- LDAP_SCOPE_SUBTREE
- filter is an LDAP search expression,
- attributes is an array of string telling with LDAP attribute to get from this request
*/
func (self *Ldap) Search(base string, scope int, filter string, attributes []string) (*LdapMessage, error) {
var attrsonly int = 0 // false: returns all, true, returns only attributes without values
_base := C.CString(base)
defer C.free(unsafe.Pointer(_base))
_filter := C.CString(filter)
defer C.free(unsafe.Pointer(_filter))
// transform []string to C.char** null terminated array (attributes argument)
_attributes := make([]*C.char, len(attributes)+1) // default set to nil (NULL in C)
for i, arg := range attributes {
_attributes[i] = C.CString(arg)
defer C.free(unsafe.Pointer(_attributes[i]))
}
var msg *C.LDAPMessage
// DEPRECATED
// API: int ldap_search_s (LDAP *ld, char *base, int scope, char *filter, char **attrs, int attrsonly, LdapMessage * ldap_res)
rv := int(C.ldap_search_s(self.conn, _base, C.int(scope), _filter, &_attributes[0], C.int(attrsonly), &msg))
if rv == LDAP_OPT_SUCCESS {
_msg := new(LdapMessage)
_msg.ldap = self
_msg.errno = rv
_msg.msg = msg
return _msg, nil
}
return nil, errors.New(fmt.Sprintf("LDAP::Search() error : %d (%s)", rv, ErrorToString(rv)))
}
// ------------------------------------- Ldap* method (object oriented) -------------------------------------------------------------------
// Append() adds an LdapAttribute to self LdapEntry
func (self *LdapEntry) Append(a LdapAttribute){
self.values = append(self.values, a)
}
// String() is used for fmt.Println(self)
//
func (self *LdapAttribute) String() string{
return self.ToText()
}
// ToText() returns a text string representation of LdapAttribute
// avoiding displaying binary data.
//
func (self *LdapAttribute) ToText() string{
var list []string
for _, a := range self.Values() {
if (!_isPrint(a)) {
list = append(list, fmt.Sprintf("binary-data[%d]", len(a)))
} else {
list = append(list, a)
}
}
return fmt.Sprintf("%s: [%s]", self.name, strings.Join(list, ", "))
}
// Name() return attribute name
func (self *LdapAttribute) Name() string{
return self.name
}
// Values() returns array values for self LdapAttribute
//
func (self *LdapAttribute) Values() []string{
return self.values
}
// _isPrint() returns true if str is printable
//
// @private method
func _isPrint(str string) bool{
for _, c := range str{
if !strconv.IsPrint(rune(c)) {
return false
}
}
return true
}
// IsPrint() returns true is self LdapAttribute is printable.
func (self *LdapAttribute) IsPrint() bool{
for _, a := range self.Values() {
if (!_isPrint(a)) {
return false
}
}
return true
}
// Dn() returns DN (Distinguish Name) for self LdapEntry
func (self *LdapEntry) Dn() string{
return self.dn
}
// Attributes() returns an array of LdapAttribute
func (self *LdapEntry) Attributes() []LdapAttribute{
return self.values
}
// Print() allow printing self LdapEntry with fmt.Println()
func (self *LdapEntry) String() string {
return self.ToText()
}
// GetValuesByName() get a list of values for self LdapEntry, using "name" attribute
func (self *LdapEntry) GetValuesByName(attrib string) []string{
for _, a := range self.values{
if a.Name() == attrib {
return a.values
}
}
return []string{}
}
// GetOneValueByName() ; a quick way to get a single attribute value
func (self *LdapEntry) GetOneValueByName(attrib string) string, err{
for _, a := range self.values{
if a.Name() == attrib {
return a.values[0], nil
}
}
return "", errors.New(fmt.Sprintf("LdapEntry::GetOneValueByName() error : attribute %s not found", attrib))
}
// ToText() return a string representating self LdapEntry
func (self *LdapEntry) ToText() string{
txt := fmt.Sprintf("dn: %s\n", self.dn)
for _, a := range self.values{
txt = txt + fmt.Sprintf("%s\n", a.ToText())
}
return txt
}
// Append() add e to LdapSearchResult array
func (self *LdapSearchResult) Append(e LdapEntry){
self.entries = append(self.entries, e)
}
// ToText() : a quick way to print an LdapSearchResult
func (self *LdapSearchResult) ToText() string{
txt := fmt.Sprintf("# query : %s\n", self.filter)
txt = txt + fmt.Sprintf("# num results : %d\n", self.Count())
txt = txt + fmt.Sprintf("# search : %s\n", self.Filter())
txt = txt + fmt.Sprintf("# base : %s\n", self.Base())
txt = txt + fmt.Sprintf("# attributes : [%s]\n", strings.Join(self.Attributes(), ", "))
for _, e := range self.entries{
txt = txt + fmt.Sprintf("%s\n", e.ToText())
}
return txt
}
// String() : used for fmt.Println(self)
func (self *LdapSearchResult) String() string{
return self.ToText()
}
// Entries() : returns an array of LdapEntry for self
func (self *LdapSearchResult) Entries() []LdapEntry{
return self.entries
}
// Count() : returns number of results for self search.
func (self *LdapSearchResult) Count() int{
return len(self.entries)
}
// Filter() : returns filter for self search
func (self *LdapSearchResult) Filter() string{
return self.filter
}
// Filter() : returns base DN for self search
func (self *LdapSearchResult) Base() string{
return self.base
}
// Filter() : returns scope for self search
func (self *LdapSearchResult) Scope() int{
return self.scope
}
// Filter() : returns an array of attributes used for this actual search
func (self *LdapSearchResult) Attributes() []string{
return self.attributes
}
// SearchAll() : a quick way to make search. This method returns an LdapSearchResult with all necessary methods to
// access data. Result is a collection (tree) of []LdapEntry / []LdapAttribute.
//
func (self *Ldap) SearchAll(base string, scope int, filter string, attributes []string) (*LdapSearchResult, error) {
sr := new(LdapSearchResult)
sr.ldap = self
sr.base = base
sr.scope = scope
sr.filter = filter
sr.attributes = attributes
// Search(base string, scope int, filter string, attributes []string) (*LDAPMessage, error)
result, err := self.Search(base, scope, filter, attributes)
if err != nil {
fmt.Println(err)
return sr, err
}
// Free LDAP::Result() allocated data
defer result.MsgFree()
e := result.FirstEntry()
for e != nil {
_e := new(LdapEntry)
_e.dn = e.GetDn()
attr, _ := e.FirstAttribute()
for attr != "" {
_attr := new(LdapAttribute)
_attr.values = e.GetValues(attr)
_attr.name = attr
_e.Append(*_attr)
attr, _ = e.NextAttribute()
}
sr.Append(*_e)
e = e.NextEntry()
}
return sr, nil
}
golang-openldap-0.2/options-errors.go 0000664 0000000 0000000 00000005144 11766376717 0020007 0 ustar 00root root 0000000 0000000 package openldap
/*
#include
static inline char* to_charptr(const void* s) { return (char*)s; }
*/
// #cgo CFLAGS: -DLDAP_DEPRECATED=1
// #cgo linux CFLAGS: -DLINUX=1
// #cgo LDFLAGS: -lldap -llber
import "C"
import (
"errors"
"fmt"
"unsafe"
)
// FIXME : support all kind of option (int, int*, ...)
func (self *Ldap) SetOption(opt int, val int) error {
// API: ldap_set_option (LDAP *ld,int option, LDAP_CONST void *invalue));
rv := C.ldap_set_option(self.conn, C.int(opt), unsafe.Pointer(&val))
if rv == LDAP_OPT_SUCCESS {
return nil
}
return errors.New(fmt.Sprintf("LDAP::SetOption() error (%d) : %s", int(rv), ErrorToString(int(rv))))
}
// FIXME : support all kind of option (int, int*, ...) should take care of all return type for ldap_get_option
func (self *Ldap) GetOption(opt int) (val int, err error) {
// API: int ldap_get_option (LDAP *ld,int option, LDAP_CONST void *invalue));
rv := C.ldap_get_option(self.conn, C.int(opt), unsafe.Pointer(&val))
if rv == LDAP_OPT_SUCCESS {
return val, nil
}
return 0, errors.New(fmt.Sprintf("LDAP::GetOption() error (%d) : %s", rv, ErrorToString(int(rv))))
}
/*
** WORK IN PROGRESS!
**
** OpenLDAP reentrancy/thread-safeness should be dynamically
** checked using ldap_get_option().
**
** The -lldap implementation is not thread-safe.
**
** The -lldap_r implementation is:
** LDAP_API_FEATURE_THREAD_SAFE (basic thread safety)
** but also be:
** LDAP_API_FEATURE_SESSION_THREAD_SAFE
** LDAP_API_FEATURE_OPERATION_THREAD_SAFE
**
** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
** can be used to determine if -lldap_r is available at compile
** time. You must define LDAP_THREAD_SAFE if and only if you
** link with -lldap_r.
**
** If you fail to define LDAP_THREAD_SAFE when linking with
** -lldap_r or define LDAP_THREAD_SAFE when linking with -lldap,
** provided header definations and declarations may be incorrect.
**
*/
func (self *Ldap) IsThreadSafe() bool {
// fmt.Println("IsThreadSafe()")
// opt, err := self.GetOption(LDAP_API_FEATURE_THREAD_SAFE) ; fmt.Println(opt, err)
// opt, err = self.GetOption(LDAP_THREAD_SAFE) ; fmt.Println(opt, err)
// opt, err = self.GetOption(LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE) ; fmt.Println(opt, err)
//FIXME: need to implement LDAP::GetOption(LDAP_OPT_API_FEATURE_INFO)
return false
}
func ErrorToString(err int) string {
// API: char * ldap_err2string (int err )
result := C.GoString(C.to_charptr(unsafe.Pointer(C.ldap_err2string(C.int(err)))))
return result
}
func (self *Ldap) Errno() int {
opt, _ := self.GetOption(LDAP_OPT_ERROR_NUMBER)
return opt
}
golang-openldap-0.2/results.go 0000664 0000000 0000000 00000017115 11766376717 0016504 0 ustar 00root root 0000000 0000000 package openldap
/*#include
#include
#include
#include
int _berval_get_len(struct berval **ber, int i){
return ber[i]->bv_len;
}
char* _berval_get_value(struct berval **ber, int i){
return ber[i]->bv_val;
}
*/
// #cgo CFLAGS: -DLDAP_DEPRECATED=1
// #cgo linux CFLAGS: -DLINUX=1
// #cgo LDFLAGS: -lldap -llber
import "C"
import (
"errors"
"fmt"
"unsafe"
)
// ------------------------------------------ RESULTS methods ---------------------------------------------
/*
openldap C API :
int ldap_count_messages( LDAP *ld, LdapMessage *result )
LdapMessage *ldap_first_message( LDAP *ld, LdapMessage *result )
LdapMessage *ldap_next_message ( LDAP *ld, LdapMessage *message )
int ldap_count_entries( LDAP *ld, LdapMessage *result )
LdapMessage *ldap_first_entry( LDAP *ld, LdapMessage *result )
LdapMessage *ldap_next_entry ( LDAP *ld, LdapMessage *entry )
char *ldap_first_attribute(LDAP *ld, LdapMessage *entry, BerElement **berptr )
char *ldap_next_attribute (LDAP *ld, LdapMessage *entry, BerElement *ber )
char **ldap_get_values(LDAP *ld, LdapMessage *entry, char *attr)
struct berval **ldap_get_values_len(LDAP *ld, LdapMessage *entry,char *attr)
int ldap_count_values(char **vals)
int ldap_count_values_len(struct berval **vals)
void ldap_value_free(char **vals)
void ldap_value_free_len(struct berval **vals)
*/
func (self *LdapMessage) Count() int {
// API : int ldap_count_messages(LDAP *ld, LDAPMessage *chain )
// err : (count = -1)
count := int(C.ldap_count_messages(self.ldap.conn, self.msg))
if count == -1 {
panic("LDAP::Count() (ldap_count_messages) error (-1)")
}
return count
}
func (self *LdapMessage) FirstMessage() *LdapMessage {
var msg *C.LDAPMessage
msg = C.ldap_first_message(self.ldap.conn, self.msg)
if msg == nil {
return nil
}
_msg := new(LdapMessage)
_msg.ldap = self.ldap
_msg.errno = 0
_msg.msg = msg
return _msg
}
func (self *LdapMessage) NextMessage() *LdapMessage {
var msg *C.LDAPMessage
msg = C.ldap_next_message(self.ldap.conn, self.msg)
if msg == nil {
return nil
}
_msg := new(LdapMessage)
_msg.ldap = self.ldap
_msg.errno = 0
_msg.msg = msg
return _msg
}
/* an alias to ldap_count_message() ? */
func (self *LdapEntry) CountEntries() int {
// API : int ldap_count_messages(LDAP *ld, LDAPMessage *chain )
// err : (count = -1)
return int(C.ldap_count_entries(self.ldap.conn, self.entry))
}
func (self *LdapMessage) FirstEntry() *LdapEntry {
var msg *C.LDAPMessage
// API: LdapMessage *ldap_first_entry( LDAP *ld, LdapMessage *result )
msg = C.ldap_first_entry(self.ldap.conn, self.msg)
if msg == nil {
return nil
}
_msg := new(LdapEntry)
_msg.ldap = self.ldap
_msg.errno = 0
_msg.entry = msg
return _msg
}
func (self *LdapEntry) NextEntry() *LdapEntry {
var msg *C.LDAPMessage
// API: LdapMessage *ldap_next_entry ( LDAP *ld, LdapMessage *entry )
msg = C.ldap_next_entry(self.ldap.conn, self.entry)
if msg == nil {
return nil
}
_msg := new(LdapEntry)
_msg.ldap = self.ldap
_msg.errno = 0
_msg.entry = msg
return _msg
}
func (self *LdapEntry) FirstAttribute() (string, error) {
var ber *C.BerElement
// API: char *ldap_first_attribute(LDAP *ld, LdapMessage *entry, BerElement **berptr )
rv := C.ldap_first_attribute(self.ldap.conn, self.entry, &ber)
if rv == nil {
// error
return "", nil
}
self.ber = ber
return C.GoString(rv), nil
}
func (self *LdapEntry) NextAttribute() (string, error) {
// API: char *ldap_next_attribute (LDAP *ld, LdapMessage *entry, BerElement *ber )
rv := C.ldap_next_attribute(self.ldap.conn, self.entry, self.ber)
if rv == nil {
// error
return "", nil
}
return C.GoString(rv), nil
}
// private func
func sptr(p uintptr) *C.char {
return *(**C.char)(unsafe.Pointer(p))
}
// private func used to convert null terminated char*[] to go []string
func cstrings_array(x **C.char) []string {
var s []string
for p := uintptr(unsafe.Pointer(x)); sptr(p) != nil; p += unsafe.Sizeof(uintptr(0)) {
s = append(s, C.GoString(sptr(p)))
}
return s
}
/*
FIXME: does not work for binary attributes
FIXME:
If the attribute values are binary in nature, and thus not suitable to be returned as an array of char *'s, the ldap_get_values_len() routine can be used instead. It
takes the same parameters as ldap_get_values(), but returns a NULL-terminated array of pointers to berval structures, each containing the length of and a pointer to a
value.
*/
// OK for pure ASCI entries.
func (self *LdapEntry) GetValues_ascii(attr string) []string {
_attr := C.CString(attr)
defer C.free(unsafe.Pointer(_attr))
// DEPRECATED
// API: char **ldap_get_values(LDAP *ld, LdapMessage *entry, char *attr)
values := cstrings_array(C.ldap_get_values(self.ldap.conn, self.entry, _attr))
return values
}
// FIXME: need to verify binary values.
func (self *LdapEntry) GetValues(attr string) []string {
var s []string
_attr := C.CString(attr)
defer C.free(unsafe.Pointer(_attr))
var bv **C.struct_berval
//API: struct berval **ldap_get_values_len(LDAP *ld, LDAPMessage *entry, char *attr)
bv = C.ldap_get_values_len(self.ldap.conn, self.entry, _attr)
var i int
count := int(C.ldap_count_values_len(bv))
for i = 0 ; i < count; i++ {
s = append(s, C.GoStringN(C._berval_get_value(bv, C.int(i)), C._berval_get_len(bv, C.int(i))))
}
// free allocated array (bv)
C.ldap_value_free_len(bv)
return s
}
// ------------------------------------------------ RESULTS -----------------------------------------------
/*
int ldap_result ( LDAP *ld, int msgid, int all, struct timeval *timeout, LdapMessage **result );
int ldap_msgfree( LdapMessage *msg );
int ldap_msgtype( LdapMessage *msg );
int ldap_msgid ( LdapMessage *msg );
*/
// Result()
// take care to free LdapMessage result with MsgFree()
//
func (self *Ldap) Result() (*LdapMessage, error) {
var msgid int = 1
var all int = 1
var tv C.struct_timeval
tv.tv_sec = 30
var msg *C.LDAPMessage
// API: int ldap_result( LDAP *ld, int msgid, int all, struct timeval *timeout, LDAPMessage **result );
rv := C.ldap_result(self.conn, C.int(msgid), C.int(all), &tv, &msg)
if rv != LDAP_OPT_SUCCESS {
return nil, errors.New(fmt.Sprintf("LDAP::Result() error : %d (%s)", rv, ErrorToString(int(rv))))
}
_msg := new(LdapMessage)
_msg.ldap = self
_msg.errno = int(rv)
_msg.msg = msg
return _msg, nil
}
// MsgFree() is used to free LDAP::Result() allocated data
//
// returns -1 on error.
//
func (self *LdapMessage) MsgFree() int{
if self.msg != nil {
rv := C.ldap_msgfree(self.msg)
self.msg = nil
return int(rv)
}
return -1
}
// ---------------------------------------- DN Methods ---------------------------------------------------
/*
char *ldap_get_dn( LDAP *ld, LdapMessage *entry)
int ldap_str2dn( const char *str, LDAPDN *dn, unsigned flags)
void ldap_dnfree( LDAPDN dn)
int ldap_dn2str( LDAPDN dn, char **str, unsigned flags)
char **ldap_explode_dn( const char *dn, int notypes)
char **ldap_explode_rdn( const char *rdn, int notypes)
char *ldap_dn2ufn ( const char * dn )
char *ldap_dn2dcedn( const char * dn )
char *ldap_dcedn2dn( const char * dn )
char *ldap_dn2ad_canonical( const char * dn )
*/
// GetDn() return the DN (Distinguish Name) for self LdapEntry
func (self *LdapEntry) GetDn() string {
// API: char *ldap_get_dn( LDAP *ld, LDAPMessage *entry )
rv := C.ldap_get_dn(self.ldap.conn, self.entry)
defer C.free(unsafe.Pointer(rv))
if rv == nil {
err := self.ldap.Errno()
panic(fmt.Sprintf("LDAP::GetDn() error %d (%s)", err, ErrorToString(err)))
}
val := C.GoString(rv)
return val
}
golang-openldap-0.2/types.go 0000664 0000000 0000000 00000001152 11766376717 0016141 0 ustar 00root root 0000000 0000000 package openldap
/*
# include
*/
// #cgo CFLAGS: -DLDAP_DEPRECATED=1
// #cgo linux CFLAGS: -DLINUX=1
// #cgo LDFLAGS: -lldap -llber
import "C"
type Ldap struct {
conn *C.LDAP
}
type LdapMessage struct {
ldap *Ldap
// conn *C.LDAP
msg *C.LDAPMessage
errno int
}
type LdapAttribute struct{
name string
values []string
}
type LdapEntry struct {
ldap *Ldap
// conn *C.LDAP
entry *C.LDAPMessage
errno int
ber *C.BerElement
dn string
values []LdapAttribute
}
type LdapSearchResult struct{
ldap *Ldap
scope int
filter string
base string
attributes []string
entries []LdapEntry
}