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, IDMAP_BUILTIN_SID
}
 

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_smb_sid_to_unix (struct sss_idmap_ctx *ctx, struct dom_sid *smb_sid, uint32_t *id)
 Translate a Samba dom_sid stucture 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.

IDMAP_BUILTIN_SID 

The provided SID is a built-in one.


Function Documentation

const char* idmap_error_string ( enum idmap_error_code  err  ) 

Translate error code to a string.

Parameters:
[in] err Idmap 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] str String 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] ctx Idmap context
[in] domain_name Zero-terminated string with the domain name
[in] domain_sid Zero-terminated string representation of the domain SID (S-1-15-.....)
[in] range TBD 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] ctx Idmap context
[in] bin_sid Array with the binary SID
[in] length Size of the array containing the binary SID
[out] dom_sid SID 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] ctx Idmap context
[in] bin_sid Array with the binary SID
[in] length Size of the array containing the binary SID
[out] sid Zero-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] ctx Idmap context
[in] bin_sid Array with the binary SID
[in] length Size of the array containing the binary SID
[out] smb_sid Samba 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] ctx Idmap context
[in] bin_sid Array with the binary SID
[in] length Size of the array containing the binary SID
[out] id Returned 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] ctx Idmap context
[in] dom_sid SID structure
[out] bin_sid Array with the binary SID, must be freed if not needed anymore
[out] length Size 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] ctx Idmap context
[in] dom_sid SID structure
[out] sid Zero-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] ctx Idmap context
[in] dom_sid SID structure
[out] smb_sid Samba 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] ctx Idmap context
[in] dom_sid SID structure
[out] id Returned 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] ctx Idmap 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_func Function to allocate memory for the context, if NULL malloc() id used
[in] alloc_pvt Private data for allocation routine
[in] free_func Function to free the memory the context, if NULL free() id used
[out] ctx idmap 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] ctx Idmap context
[in] sid Zero-terminated string representation of the SID
[out] bin_sid Array with the binary SID, must be freed if not needed anymore
[out] length Size 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] ctx Idmap context
[in] sid Zero-terminated string representation of the SID
[out] dom_sid SID 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] ctx Idmap context
[in] sid Zero-terminated string representation of the SID
[out] smb_sid Samba 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] ctx Idmap context
[in] sid Zero-terminated string representation of the SID
[out] id Returned 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] ctx Idmap context
[in] smb_sid Samba dom_sid structure
[out] bin_sid Array with the binary SID, must be freed if not needed anymore
[out] length Size 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] ctx Idmap context
[in] smb_sid Samba dom_sid structure
[out] dom_sid SID 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] ctx Idmap context
[in] smb_sid Samba dom_sid structure
[out] sid Zero-terminated string representation of the SID, must be freed if not needed anymore
Returns:
enum idmap_error_code sss_idmap_smb_sid_to_unix ( struct sss_idmap_ctx *  ctx,
struct dom_sid *  smb_sid,
uint32_t *  id 
)

Translate a Samba dom_sid stucture to a unix UID or GID.

Parameters:
[in] ctx Idmap context
[in] smb_sid Samba dom_sid structure
[out] id Returned unix UID or GID
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] ctx Idmap context
[in] id unix UID or GID
[out] bin_sid Array with the binary SID, must be freed if not needed anymore
[out] length size 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] ctx Idmap context
[in] id unix UID or GID
[out] dom_sid SID 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] ctx Idmap context
[in] id unix UID or GID
[out] sid Zero-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

Generated on 20 Mar 2013 for sss_idmap by  doxygen 1.6.1