netatalk: ldap.c File Reference

netatalk 4.5.1
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
ldap.c File Reference
`#include <ctype.h>`
`#include <errno.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <sys/time.h>`
`#include <ldap.h>`
`#include <atalk/logger.h>`
`#include <atalk/afp.h>`
`#include <atalk/uuid.h>`
`#include <atalk/ldapconfig.h>`
`#include <atalk/errchk.h>`

## Macros
#define | LDAP_DEPRECATED 1
#define | MAX_FILTER_SIZE 512
#define | LDAP_BIN_UUID_LEN 49

## Enumerations
enum | ldapcon_t { KEEPALIVE = 1 }

## Functions
static int | ldap_getattr_fromfilter_withbase_scope (const char *searchbase, const char *filter, char *attributes[], int scope, ldapcon_t conflags, char **result)
| LDAP get attribute from filter with base and scope.
static char * | gen_uuid_filter (const char *uuidstr_in, const char *attr_filter)
| Generate LDAP filter string for UUID query.
static int | ldap_escape_filter_value (const char *src, char *dst, size_t dstlen)
int | ldap_getuuidfromname (const char *name, uuidtype_t type, char **uuid_string)
| Search UUID for name in LDAP.
int | ldap_getnamefromuuid (const char *uuidstr, char **name, uuidtype_t *type)
| LDAP search wrapper.

## Variables
int | ldap_config_valid
char * | ldap_uri
int | ldap_auth_method
char * | ldap_auth_dn
char * | ldap_auth_pw
char * | ldap_userbase
int | ldap_userscope
char * | ldap_groupbase
int | ldap_groupscope
char * | ldap_uuid_attr
char * | ldap_uuid_string
char * | ldap_name_attr
char * | ldap_group_attr
char * | ldap_uid_attr
char * | ldap_userfilter
char * | ldap_groupfilter
int | ldap_uuid_encoding
struct ldap_pref | ldap_prefs []
struct pref_array | prefs_array []

## Macro Definition Documentation

## ◆ LDAP_BIN_UUID_LEN

#define LDAP_BIN_UUID_LEN 49

## ◆ LDAP_DEPRECATED

#define LDAP_DEPRECATED 1

## ◆ MAX_FILTER_SIZE

#define MAX_FILTER_SIZE 512

## Enumeration Type Documentation

## ◆ ldapcon_t

enum ldapcon_t

Enumerator
KEEPALIVE |

## Function Documentation

## ◆ gen_uuid_filter()

char * gen_uuid_filter | ( | const char * | uuidstr_in,
|  | const char * | attr_filter )
| static

Generate LDAP filter string for UUID query.

Parameters

  [in] | uuidstr_in | the UUID as string
  [in] | attr_filter | optional attribute

Returns
  pointer to static filter string

## ◆ ldap_escape_filter_value()

int ldap_escape_filter_value | ( | const char * | src,
|  | char * | dst,
|  | size_t | dstlen )
| static

## ◆ ldap_getattr_fromfilter_withbase_scope()

int ldap_getattr_fromfilter_withbase_scope | ( | const char * | searchbase,
|  | const char * | filter,
|  | char * | attributes[],
|  | int | scope,
|  | ldapcon_t | conflags,
|  | char ** | result )
| static

LDAP get attribute from filter with base and scope.

Parameters

  searchbase | Base DN for LDAP search
  filter | LDAP search filter
  attributes | Array of attribute names to retrieve
  scope | Search scope (LDAP_SCOPE_BASE, LDAP_SCOPE_ONELEVEL, LDAP_SCOPE_SUBTREE)
  conflags | Connection flags (KEEPALIVE)
  result | unique search result, allocated here, caller must free

Returns
  -1 on error
  0 nothing found
  1 successful search, result int 'result'

All connection managment to the LDAP server is done here. Just set KEEPALIVE if you know you will be dispatching more than one search in a row, then don't set it with the last search. You MUST dispatch the queries timely, otherwise the LDAP handle might timeout.

## ◆ ldap_getnamefromuuid()

int ldap_getnamefromuuid | ( | const char * | uuidstr,
|  | char ** | name,
|  | uuidtype_t * | type )

LDAP search wrapper.

returns allocated storage in name, caller must free it

Parameters

  [in] | uuidstr | uuid to search as ascii string
  [out] | name | return pointer to name as allocated string
  [out] | type | return type: USER or GROUP

Returns
  0 on success, -1 on errror or not found

## ◆ ldap_getuuidfromname()

int ldap_getuuidfromname | ( | const char * | name,
|  | uuidtype_t | type,
|  | char ** | uuid_string )

Search UUID for name in LDAP.

Caller must free uuid_string when done with it

Parameters

  [in] | name | name to search
  [in] | type | type of USER or GROUP
  [out] | uuid_string | result as pointer to allocated UUID-string

Returns
  0 on success, -1 on error or not found

## Variable Documentation

## ◆ ldap_auth_dn

char* ldap_auth_dn

## ◆ ldap_auth_method

int ldap_auth_method

## ◆ ldap_auth_pw

char* ldap_auth_pw

## ◆ ldap_config_valid

int ldap_config_valid

## ◆ ldap_group_attr

char* ldap_group_attr

## ◆ ldap_groupbase

char* ldap_groupbase

## ◆ ldap_groupfilter

char* ldap_groupfilter

## ◆ ldap_groupscope

int ldap_groupscope

## ◆ ldap_name_attr

char* ldap_name_attr

## ◆ ldap_prefs

struct ldap_pref ldap_prefs[]

Initial value:
= {
{&ldap_uri, "ldap uri", 0, 0, -1, -1},
{&ldap_auth_method, "ldap auth method", 1, 1, -1, -1},
{&ldap_auth_dn, "ldap auth dn", 0, 0, 0, 0},
{&ldap_auth_pw, "ldap auth pw", 0, 0, 0, 0},
{&ldap_userbase, "ldap userbase", 0, 0, -1, -1},
{&ldap_userscope, "ldap userscope", 1, 1, -1, -1},
{&ldap_groupbase, "ldap groupbase", 0, 0, -1, -1},
{&ldap_groupscope, "ldap groupscope", 1, 1, -1, -1},
{&ldap_uuid_attr, "ldap uuid attr", 0, 0, -1, -1},
{&ldap_uuid_string, "ldap uuid string", 0, 0, 0, 0},
{&ldap_name_attr, "ldap name attr", 0, 0, -1, -1},
{&ldap_group_attr, "ldap group attr", 0, 0, -1, -1},
{&ldap_uid_attr, "ldap uid attr", 0, 0, 0, 0},
{&ldap_uuid_encoding, "ldap uuid encoding", 1, 1, 0, 0},
{&ldap_userfilter, "ldap user filter", 0, 0, 0, 0},
{&ldap_groupfilter, "ldap group filter", 0, 0, 0, 0},
{&ldap_auth_pw, "ldap auth pw", 0, 0, 0, 0},
{NULL, NULL, 0, 0, 0, 0}
}
ldap_groupscope
int ldap_groupscope
Definition ldap.c:53
ldap_uri
char * ldap_uri
Definition ldap.c:46
ldap_userscope
int ldap_userscope
Definition ldap.c:51
ldap_userbase
char * ldap_userbase
Definition ldap.c:50
ldap_groupbase
char * ldap_groupbase
Definition ldap.c:52
ldap_uuid_encoding
int ldap_uuid_encoding
Definition ldap.c:61
ldap_uuid_string
char * ldap_uuid_string
Definition ldap.c:55
ldap_group_attr
char * ldap_group_attr
Definition ldap.c:57
ldap_auth_method
int ldap_auth_method
Definition ldap.c:47
ldap_auth_dn
char * ldap_auth_dn
Definition ldap.c:48
ldap_auth_pw
char * ldap_auth_pw
Definition ldap.c:49
ldap_uuid_attr
char * ldap_uuid_attr
Definition ldap.c:54
ldap_uid_attr
char * ldap_uid_attr
Definition ldap.c:58
ldap_groupfilter
char * ldap_groupfilter
Definition ldap.c:60
ldap_userfilter
char * ldap_userfilter
Definition ldap.c:59
ldap_name_attr
char * ldap_name_attr
Definition ldap.c:56
NULL
#define NULL
Definition utf8util.c:47

## ◆ ldap_uid_attr

char* ldap_uid_attr

## ◆ ldap_uri

char* ldap_uri

## ◆ ldap_userbase

char* ldap_userbase

## ◆ ldap_userfilter

char* ldap_userfilter

## ◆ ldap_userscope

int ldap_userscope

## ◆ ldap_uuid_attr

char* ldap_uuid_attr

## ◆ ldap_uuid_encoding

int ldap_uuid_encoding

## ◆ ldap_uuid_string

char* ldap_uuid_string

## ◆ prefs_array

struct pref_array prefs_array[]

Initial value:
= {
{"ldap auth method", "none", LDAP_AUTH_NONE},
{"ldap auth method", "simple", LDAP_AUTH_SIMPLE},
{"ldap userscope", "base", LDAP_SCOPE_BASE},
{"ldap userscope", "one", LDAP_SCOPE_ONELEVEL},
{"ldap userscope", "sub", LDAP_SCOPE_SUBTREE},
{"ldap groupscope", "base", LDAP_SCOPE_BASE},
{"ldap groupscope", "one", LDAP_SCOPE_ONELEVEL},
{"ldap groupscope", "sub", LDAP_SCOPE_SUBTREE},
{"ldap uuid encoding", "ms-guid", LDAP_UUID_ENCODING_MSGUID},
{"ldap uuid encoding", "string", LDAP_UUID_ENCODING_STRING},
{NULL, NULL, 0}
}
LDAP_UUID_ENCODING_MSGUID
@ LDAP_UUID_ENCODING_MSGUID
Definition ldapconfig.h:34
LDAP_UUID_ENCODING_STRING
@ LDAP_UUID_ENCODING_STRING
Definition ldapconfig.h:33