sss_idmap  1.9.2
Data Structures | Typedefs | Enumerations | Functions
Map Unix UIDs and GIDs to SIDs and back

Libsss_idmap provides a mechanism to translate a SID to a UNIX UID or GID or the other way round. More...

Data Structures

struct  sss_idmap_range
 Structure for id ranges FIXME: this struct might change when it is clear how ranges are handled on the server side. More...

Typedefs

typedef void *( idmap_alloc_func )(size_t size, void *pvt)
 Typedef for memory allocation functions.

Enumerations

enum  idmap_error_code {
  IDMAP_SUCCESS = 0, IDMAP_NOT_IMPLEMENTED, IDMAP_ERROR, IDMAP_OUT_OF_MEMORY,
  IDMAP_NO_DOMAIN, IDMAP_CONTEXT_INVALID, IDMAP_SID_INVALID, IDMAP_SID_UNKNOWN,
  IDMAP_NO_RANGE
}
 Error codes used by libsss_idmap. More...

Functions

enum idmap_error_code sss_idmap_init (idmap_alloc_func *alloc_func, void *alloc_pvt, idmap_free_func *free_func, struct sss_idmap_ctx **ctx)
 Initialize idmap context.
enum idmap_error_code sss_idmap_add_domain (struct sss_idmap_ctx *ctx, const char *domain_name, const char *domain_sid, struct sss_idmap_range *range)
 Add a domain to the idmap context.
enum idmap_error_code sss_idmap_sid_to_unix (struct sss_idmap_ctx *ctx, const char *sid, uint32_t *id)
 Translate SID to a unix UID or GID.
enum idmap_error_code sss_idmap_dom_sid_to_unix (struct sss_idmap_ctx *ctx, struct sss_dom_sid *dom_sid, uint32_t *id)
 Translate a SID stucture to a unix UID or GID.
enum idmap_error_code sss_idmap_bin_sid_to_unix (struct sss_idmap_ctx *ctx, uint8_t *bin_sid, size_t length, uint32_t *id)
 Translate a binary SID to a unix UID or GID.
enum idmap_error_code sss_idmap_unix_to_sid (struct sss_idmap_ctx *ctx, uint32_t id, char **sid)
 Translate unix UID or GID to a SID.
enum idmap_error_code sss_idmap_unix_to_dom_sid (struct sss_idmap_ctx *ctx, uint32_t id, struct sss_dom_sid **dom_sid)
 Translate unix UID or GID to a SID structure.
enum idmap_error_code sss_idmap_unix_to_bin_sid (struct sss_idmap_ctx *ctx, uint32_t id, uint8_t **bin_sid, size_t *length)
 Translate unix UID or GID to a binary SID.
enum idmap_error_code sss_idmap_free (struct sss_idmap_ctx *ctx)
 Free all the allocated memory of the idmap context.
const char * idmap_error_string (enum idmap_error_code err)
 Translate error code to a string.
bool is_domain_sid (const char *str)
 Check if given string can be used as domain SID.
enum idmap_error_code sss_idmap_bin_sid_to_dom_sid (struct sss_idmap_ctx *ctx, const uint8_t *bin_sid, size_t length, struct sss_dom_sid **dom_sid)
 Convert binary SID to SID structure.
enum idmap_error_code sss_idmap_bin_sid_to_sid (struct sss_idmap_ctx *ctx, const uint8_t *bin_sid, size_t length, char **sid)
 Convert binary SID to SID string.
enum idmap_error_code sss_idmap_dom_sid_to_bin_sid (struct sss_idmap_ctx *ctx, struct sss_dom_sid *dom_sid, uint8_t **bin_sid, size_t *length)
 Convert SID structure to binary SID.
enum idmap_error_code sss_idmap_sid_to_bin_sid (struct sss_idmap_ctx *ctx, const char *sid, uint8_t **bin_sid, size_t *length)
 Convert SID string to binary SID.
enum idmap_error_code sss_idmap_dom_sid_to_sid (struct sss_idmap_ctx *ctx, struct sss_dom_sid *dom_sid, char **sid)
 Convert SID structure to SID string.
enum idmap_error_code sss_idmap_sid_to_dom_sid (struct sss_idmap_ctx *ctx, const char *sid, struct sss_dom_sid **dom_sid)
 Convert SID string to SID structure.
enum idmap_error_code sss_idmap_sid_to_smb_sid (struct sss_idmap_ctx *ctx, const char *sid, struct dom_sid **smb_sid)
 Convert SID string to Samba dom_sid structure.
enum idmap_error_code sss_idmap_smb_sid_to_sid (struct sss_idmap_ctx *ctx, struct dom_sid *smb_sid, char **sid)
 Convert Samba dom_sid structure to SID string.
enum idmap_error_code sss_idmap_dom_sid_to_smb_sid (struct sss_idmap_ctx *ctx, struct sss_dom_sid *dom_sid, struct dom_sid **smb_sid)
 Convert SID stucture to Samba dom_sid structure.
enum idmap_error_code sss_idmap_smb_sid_to_dom_sid (struct sss_idmap_ctx *ctx, struct dom_sid *smb_sid, struct sss_dom_sid **dom_sid)
 Convert Samba dom_sid structure to SID structure.
enum idmap_error_code sss_idmap_bin_sid_to_smb_sid (struct sss_idmap_ctx *ctx, const uint8_t *bin_sid, size_t length, struct dom_sid **smb_sid)
 Convert binary SID to Samba dom_sid structure.
enum idmap_error_code sss_idmap_smb_sid_to_bin_sid (struct sss_idmap_ctx *ctx, struct dom_sid *smb_sid, uint8_t **bin_sid, size_t *length)
 Convert Samba dom_sid structure to binary SID.

Detailed Description

Libsss_idmap provides a mechanism to translate a SID to a UNIX UID or GID or the other way round.

Enumeration Type Documentation

Error codes used by libsss_idmap.

Enumerator:
IDMAP_SUCCESS 

Success.

IDMAP_NOT_IMPLEMENTED 

Function is not yet implemented.

IDMAP_ERROR 

General error.

IDMAP_OUT_OF_MEMORY 

Ran out of memory during processing.

IDMAP_NO_DOMAIN 

No domain added.

IDMAP_CONTEXT_INVALID 

The provided idmap context is invalid.

IDMAP_SID_INVALID 

The provided SID is invalid.

IDMAP_SID_UNKNOWN 

The provided SID was not found.

IDMAP_NO_RANGE 

The provided UID or GID could not be mapped.

Function Documentation

const char* idmap_error_string ( enum idmap_error_code  err)

Translate error code to a string.

Parameters
[in]errIdmap error code
Returns
  • Error description as a zero-terminated string
bool is_domain_sid ( const char *  str)

Check if given string can be used as domain SID.

Parameters
[in]strString to check
Returns
  • true: String can be used as domain SID
  • false: String can not be used as domain SID
enum idmap_error_code sss_idmap_add_domain ( struct sss_idmap_ctx *  ctx,
const char *  domain_name,
const char *  domain_sid,
struct sss_idmap_range range 
)

Add a domain to the idmap context.

Parameters
[in]ctxIdmap context
[in]domain_nameZero-terminated string with the domain name
[in]domain_sidZero-terminated string representation of the domain SID (S-1-15-.....)
[in]rangeTBD Some information about the id ranges of this domain
Returns
enum idmap_error_code sss_idmap_bin_sid_to_dom_sid ( struct sss_idmap_ctx *  ctx,
const uint8_t *  bin_sid,
size_t  length,
struct sss_dom_sid **  dom_sid 
)

Convert binary SID to SID structure.

Parameters
[in]ctxIdmap context
[in]bin_sidArray with the binary SID
[in]lengthSize of the array containing the binary SID
[out]dom_sidSID structure, must be freed if not needed anymore
Returns
enum idmap_error_code sss_idmap_bin_sid_to_sid ( struct sss_idmap_ctx *  ctx,
const uint8_t *  bin_sid,
size_t  length,
char **  sid 
)

Convert binary SID to SID string.

Parameters
[in]ctxIdmap context
[in]bin_sidArray with the binary SID
[in]lengthSize of the array containing the binary SID
[out]sidZero-terminated string representation of the SID, must be freed if not needed anymore
Returns
enum idmap_error_code sss_idmap_bin_sid_to_smb_sid ( struct sss_idmap_ctx *  ctx,
const uint8_t *  bin_sid,
size_t  length,
struct dom_sid **  smb_sid 
)

Convert binary SID to Samba dom_sid structure.

Parameters
[in]ctxIdmap context
[in]bin_sidArray with the binary SID
[in]lengthSize of the array containing the binary SID
[out]smb_sidSamba dom_sid structure, must be freed if not needed anymore
Returns
enum idmap_error_code sss_idmap_bin_sid_to_unix ( struct sss_idmap_ctx *  ctx,
uint8_t *  bin_sid,
size_t  length,
uint32_t *  id 
)

Translate a binary SID to a unix UID or GID.

Parameters
[in]ctxIdmap context
[in]bin_sidArray with the binary SID
[in]lengthSize of the array containing the binary SID
[out]idReturned unix UID or GID
Returns
enum idmap_error_code sss_idmap_dom_sid_to_bin_sid ( struct sss_idmap_ctx *  ctx,
struct sss_dom_sid *  dom_sid,
uint8_t **  bin_sid,
size_t *  length 
)

Convert SID structure to binary SID.

Parameters
[in]ctxIdmap context
[in]dom_sidSID structure
[out]bin_sidArray with the binary SID, must be freed if not needed anymore
[out]lengthSize of the array containing the binary SID
Returns
enum idmap_error_code sss_idmap_dom_sid_to_sid ( struct sss_idmap_ctx *  ctx,
struct sss_dom_sid *  dom_sid,
char **  sid 
)

Convert SID structure to SID string.

Parameters
[in]ctxIdmap context
[in]dom_sidSID structure
[out]sidZero-terminated string representation of the SID, must be freed if not needed anymore
Returns
enum idmap_error_code sss_idmap_dom_sid_to_smb_sid ( struct sss_idmap_ctx *  ctx,
struct sss_dom_sid *  dom_sid,
struct dom_sid **  smb_sid 
)

Convert SID stucture to Samba dom_sid structure.

Parameters
[in]ctxIdmap context
[in]dom_sidSID structure
[out]smb_sidSamba dom_sid structure, must be freed if not needed anymore
Returns
enum idmap_error_code sss_idmap_dom_sid_to_unix ( struct sss_idmap_ctx *  ctx,
struct sss_dom_sid *  dom_sid,
uint32_t *  id 
)

Translate a SID stucture to a unix UID or GID.

Parameters
[in]ctxIdmap context
[in]dom_sidSID structure
[out]idReturned unix UID or GID
Returns
enum idmap_error_code sss_idmap_free ( struct sss_idmap_ctx *  ctx)

Free all the allocated memory of the idmap context.

Parameters
[in]ctxIdmap context
Returns
enum idmap_error_code sss_idmap_init ( idmap_alloc_func alloc_func,
void *  alloc_pvt,
idmap_free_func *  free_func,
struct sss_idmap_ctx **  ctx 
)

Initialize idmap context.

Parameters
[in]alloc_funcFunction to allocate memory for the context, if NULL malloc() id used
[in]alloc_pvtPrivate data for allocation routine
[in]free_funcFunction to free the memory the context, if NULL free() id used
[out]ctxidmap context
Returns
enum idmap_error_code sss_idmap_sid_to_bin_sid ( struct sss_idmap_ctx *  ctx,
const char *  sid,
uint8_t **  bin_sid,
size_t *  length 
)

Convert SID string to binary SID.

Parameters
[in]ctxIdmap context
[in]sidZero-terminated string representation of the SID
[out]bin_sidArray with the binary SID, must be freed if not needed anymore
[out]lengthSize of the array containing the binary SID
Returns
enum idmap_error_code sss_idmap_sid_to_dom_sid ( struct sss_idmap_ctx *  ctx,
const char *  sid,
struct sss_dom_sid **  dom_sid 
)

Convert SID string to SID structure.

Parameters
[in]ctxIdmap context
[in]sidZero-terminated string representation of the SID
[out]dom_sidSID structure, must be freed if not needed anymore
Returns
enum idmap_error_code sss_idmap_sid_to_smb_sid ( struct sss_idmap_ctx *  ctx,
const char *  sid,
struct dom_sid **  smb_sid 
)

Convert SID string to Samba dom_sid structure.

Parameters
[in]ctxIdmap context
[in]sidZero-terminated string representation of the SID
[out]smb_sidSamba dom_sid structure, must be freed if not needed anymore
Returns
enum idmap_error_code sss_idmap_sid_to_unix ( struct sss_idmap_ctx *  ctx,
const char *  sid,
uint32_t *  id 
)

Translate SID to a unix UID or GID.

Parameters
[in]ctxIdmap context
[in]sidZero-terminated string representation of the SID
[out]idReturned unix UID or GID
Returns
enum idmap_error_code sss_idmap_smb_sid_to_bin_sid ( struct sss_idmap_ctx *  ctx,
struct dom_sid *  smb_sid,
uint8_t **  bin_sid,
size_t *  length 
)

Convert Samba dom_sid structure to binary SID.

Parameters
[in]ctxIdmap context
[in]smb_sidSamba dom_sid structure
[out]bin_sidArray with the binary SID, must be freed if not needed anymore
[out]lengthSize of the array containing the binary SID
Returns
enum idmap_error_code sss_idmap_smb_sid_to_dom_sid ( struct sss_idmap_ctx *  ctx,
struct dom_sid *  smb_sid,
struct sss_dom_sid **  dom_sid 
)

Convert Samba dom_sid structure to SID structure.

Parameters
[in]ctxIdmap context
[in]smb_sidSamba dom_sid structure
[out]dom_sidSID structure, must be freed if not needed anymore
Returns
enum idmap_error_code sss_idmap_smb_sid_to_sid ( struct sss_idmap_ctx *  ctx,
struct dom_sid *  smb_sid,
char **  sid 
)

Convert Samba dom_sid structure to SID string.

Parameters
[in]ctxIdmap context
[in]smb_sidSamba dom_sid structure
[out]sidZero-terminated string representation of the SID, must be freed if not needed anymore
Returns
enum idmap_error_code sss_idmap_unix_to_bin_sid ( struct sss_idmap_ctx *  ctx,
uint32_t  id,
uint8_t **  bin_sid,
size_t *  length 
)

Translate unix UID or GID to a binary SID.

Parameters
[in]ctxIdmap context
[in]idunix UID or GID
[out]bin_sidArray with the binary SID, must be freed if not needed anymore
[out]lengthsize of the array containing the binary SID
Returns
  • IDMAP_NO_DOMAIN: No domains are added to the idmap context
  • IDMAP_NO_RANGE: The provided ID cannot be found in the domains added to the idmap context
enum idmap_error_code sss_idmap_unix_to_dom_sid ( struct sss_idmap_ctx *  ctx,
uint32_t  id,
struct sss_dom_sid **  dom_sid 
)

Translate unix UID or GID to a SID structure.

Parameters
[in]ctxIdmap context
[in]idunix UID or GID
[out]dom_sidSID structure, must be freed if not needed anymore
Returns
  • IDMAP_NO_DOMAIN: No domains are added to the idmap context
  • IDMAP_NO_RANGE: The provided ID cannot be found in the domains added to the idmap context
enum idmap_error_code sss_idmap_unix_to_sid ( struct sss_idmap_ctx *  ctx,
uint32_t  id,
char **  sid 
)

Translate unix UID or GID to a SID.

Parameters
[in]ctxIdmap context
[in]idunix UID or GID
[out]sidZero-terminated string representation of the SID, must be freed if not needed anymore
Returns
  • IDMAP_NO_DOMAIN: No domains are added to the idmap context
  • IDMAP_NO_RANGE: The provided ID cannot be found in the domains added to the idmap context