mapiproxy/servers/default/nspi/emsabp.c File Reference

Address Book Provider implementation. More...

#include "mapiproxy/dcesrv_mapiproxy.h"
#include "dcesrv_exchange_nsp.h"

Defines

#define TEVENT_DEPRECATED

Functions

_PUBLIC_ enum MAPISTATUS emsabp_ab_container_by_id (TALLOC_CTX *mem_ctx, struct emsabp_context *emsabp_ctx, uint32_t ContainerID, struct ldb_message **ldb_msg)
_PUBLIC_ enum MAPISTATUS emsabp_ab_container_enum (TALLOC_CTX *mem_ctx, struct emsabp_context *emsabp_ctx, uint32_t ContainerID, struct ldb_result **ldb_resp)
_PUBLIC_ bool emsabp_destructor (void *data)
_PUBLIC_ enum MAPISTATUS emsabp_EphemeralEntryID_to_Binary_r (TALLOC_CTX *mem_ctx, struct EphemeralEntryID *ephEntryID, struct Binary_r *bin)
_PUBLIC_ enum MAPISTATUS emsabp_fetch_attrs (TALLOC_CTX *mem_ctx, struct emsabp_context *emsabp_ctx, struct PropertyRow_r *aRow, uint32_t MId, uint32_t dwFlags, struct SPropTagArray *pPropTags)
_PUBLIC_ enum MAPISTATUS emsabp_fetch_attrs_from_msg (TALLOC_CTX *mem_ctx, struct emsabp_context *emsabp_ctx, struct PropertyRow_r *aRow, struct ldb_message *ldb_msg, uint32_t MId, uint32_t dwFlags, struct SPropTagArray *pPropTags)
_PUBLIC_ enum MAPISTATUS emsabp_get_account_info (TALLOC_CTX *mem_ctx, struct emsabp_context *emsabp_ctx, const char *username, struct ldb_message **ldb_msg)
_PUBLIC_ enum MAPISTATUS emsabp_get_CreationTemplatesTable (TALLOC_CTX *mem_ctx, struct emsabp_context *emsabp_ctx, uint32_t dwFlags, struct PropertyRowSet_r **SRowSet)
_PUBLIC_ enum MAPISTATUS emsabp_get_HierarchyTable (TALLOC_CTX *mem_ctx, struct emsabp_context *emsabp_ctx, uint32_t dwFlags, struct PropertyRowSet_r **SRowSet)
_PUBLIC_ struct emsabp_contextemsabp_init (struct loadparm_context *lp_ctx, TDB_CONTEXT *tdb_ctx)
_PUBLIC_ enum MAPISTATUS emsabp_PermanentEntryID_to_Binary_r (TALLOC_CTX *mem_ctx, struct PermanentEntryID *permEntryID, struct Binary_r *bin)
_PUBLIC_ void * emsabp_query (TALLOC_CTX *mem_ctx, struct emsabp_context *emsabp_ctx, struct ldb_message *msg, uint32_t ulPropTag, uint32_t MId, uint32_t dwFlags)
_PUBLIC_ enum MAPISTATUS emsabp_search (TALLOC_CTX *mem_ctx, struct emsabp_context *emsabp_ctx, struct PropertyTagArray_r *MIds, struct Restriction_r *restriction, struct STAT *pStat, uint32_t limit)
_PUBLIC_ enum MAPISTATUS emsabp_search_dn (struct emsabp_context *emsabp_ctx, const char *dn, struct ldb_message **ldb_res)
_PUBLIC_ enum MAPISTATUS emsabp_search_legacyExchangeDN (struct emsabp_context *emsabp_ctx, const char *legacyDN, struct ldb_message **ldb_res, bool *pbUseConfPartition)
_PUBLIC_ enum MAPISTATUS emsabp_set_EphemeralEntryID (struct emsabp_context *emsabp_ctx, uint32_t DisplayType, uint32_t MId, struct EphemeralEntryID *ephEntryID)
_PUBLIC_ enum MAPISTATUS emsabp_set_PermanentEntryID (struct emsabp_context *emsabp_ctx, uint32_t DisplayType, struct ldb_message *msg, struct PermanentEntryID *permEntryID)
_PUBLIC_ enum MAPISTATUS emsabp_table_fetch_attrs (TALLOC_CTX *mem_ctx, struct emsabp_context *emsabp_ctx, struct PropertyRow_r *aRow, uint32_t dwFlags, struct PermanentEntryID *permEntryID, struct PermanentEntryID *parentPermEntryID, struct ldb_message *msg, bool child)
_PUBLIC_ bool emsabp_verify_codepage (struct emsabp_context *emsabp_ctx, uint32_t CodePage)
_PUBLIC_ bool emsabp_verify_user (struct dcesrv_call_state *dce_call, struct emsabp_context *emsabp_ctx)

Detailed Description

Address Book Provider implementation.


Define Documentation

#define TEVENT_DEPRECATED

Function Documentation

_PUBLIC_ enum MAPISTATUS emsabp_ab_container_by_id ( TALLOC_CTX *  mem_ctx,
struct emsabp_context emsabp_ctx,
uint32_t  ContainerID,
struct ldb_message **  ldb_msg 
)

Fetch Address Book container record for given ContainerID

Parameters:
mem_ctx memory context for allocation
emsabp_ctx pointer to the EMSABP context
ContainerID id of the container to fetch
ldb_msg pointer on pointer to the LDB message returned by the function
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI_ERROR

References emsabp_search_dn(), emsabp_tdb_fetch_dn_from_MId(), emsabp_context::samdb_ctx, and emsabp_context::tdb_ctx.

Referenced by dcesrv_NspiResolveNames(), dcesrv_NspiResolveNamesW(), and emsabp_ab_container_enum().

_PUBLIC_ enum MAPISTATUS emsabp_ab_container_enum ( TALLOC_CTX *  mem_ctx,
struct emsabp_context emsabp_ctx,
uint32_t  ContainerID,
struct ldb_result **  ldb_resp 
)

Enumerate AB container entries

Parameters:
mem_ctx pointer to the memory context
emsabp_ctx pointer to the EMSABP context
ContainerID id of the container to fetch
ldb_res pointer on pointer to the LDB result returned by the function
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI error

References emsabp_ab_container_by_id(), and emsabp_context::samdb_ctx.

Referenced by dcesrv_NspiQueryRows().

_PUBLIC_ bool emsabp_destructor ( void *  data  ) 
_PUBLIC_ enum MAPISTATUS emsabp_EphemeralEntryID_to_Binary_r ( TALLOC_CTX *  mem_ctx,
struct EphemeralEntryID ephEntryID,
struct Binary_r *  bin 
)

Map an EphemeralEntryID structure into a Binary_r structure

Parameters:
mem_ctx pointer to the memory context
ephEntryID pointer to the Ephemeral EntryID structure
bin pointer to the Binary_r structure the server will return
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI_E_INVALID_PARAMETER

References EphemeralEntryID::DisplayType, EphemeralEntryID::ID_type, EphemeralEntryID::MId, EphemeralEntryID::ProviderUID, EphemeralEntryID::R1, EphemeralEntryID::R2, EphemeralEntryID::R3, and EphemeralEntryID::R4.

Referenced by emsabp_query().

_PUBLIC_ enum MAPISTATUS emsabp_fetch_attrs ( TALLOC_CTX *  mem_ctx,
struct emsabp_context emsabp_ctx,
struct PropertyRow_r *  aRow,
uint32_t  MId,
uint32_t  dwFlags,
struct SPropTagArray *  pPropTags 
)

Builds the SRow array entry for the specified MId.

The function retrieves the DN associated to the specified MId within its on-memory TDB database. It next fetches the LDB record matching the DN and finally retrieve the requested properties for this record.

Parameters:
mem_ctx pointer to the memory context
emsabp_ctx pointer to the EMSABP context
aRow pointer to the SRow structure where results will be stored
MId MId to fetch properties for
dwFlags bit flags specifying whether or not the server must return the values of the property PidTagEntryId in the Ephemeral or Permanent Entry ID format
pPropTags pointer to the property tags array
Note:
We currently assume records are users.ldb
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI error

References emsabp_query(), emsabp_tdb_fetch_dn_from_MId(), emsabp_context::mem_ctx, emsabp_context::samdb_ctx, emsabp_context::tdb_ctx, and emsabp_context::ttdb_ctx.

Referenced by dcesrv_NspiGetMatches(), dcesrv_NspiGetProps(), dcesrv_NspiQueryRows(), and dcesrv_NspiSeekEntries().

_PUBLIC_ enum MAPISTATUS emsabp_fetch_attrs_from_msg ( TALLOC_CTX *  mem_ctx,
struct emsabp_context emsabp_ctx,
struct PropertyRow_r *  aRow,
struct ldb_message *  ldb_msg,
uint32_t  MId,
uint32_t  dwFlags,
struct SPropTagArray *  pPropTags 
)

Build the SRow array entry for the specified ldb_message.

Parameters:
mem_ctx pointer to the memory context
emsabp_ctx pointer to the EMSABP context
aRow pointer to the SRow structure where results will be stored
ldb_msg ldb_message record to fetch results from
MId MId of the entry to fetch (may be 0)
dwFlags input call flags (default to 0)
pPropTags pointer to the property tags array
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI error

References emsabp_query(), emsabp_tdb_fetch_MId(), emsabp_tdb_insert(), and emsabp_context::ttdb_ctx.

Referenced by dcesrv_NspiQueryRows(), dcesrv_NspiResolveNames(), and dcesrv_NspiResolveNamesW().

_PUBLIC_ enum MAPISTATUS emsabp_get_account_info ( TALLOC_CTX *  mem_ctx,
struct emsabp_context emsabp_ctx,
const char *  username,
struct ldb_message **  ldb_msg 
)

Get AD record for Mail-enabled account

Parameters:
mem_ctx pointer to the session context
emsabp_ctx pointer to the EMSABP context
username User common name
ldb_msg Pointer on pointer to ldb_message to return result to
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI_E_NOT_ENOUGH_RESOURCES, MAPI_E_NOT_FOUND or MAPI_E_CORRUPT_STORE

References emsabp_context::samdb_ctx.

Referenced by emsabp_verify_user().

_PUBLIC_ enum MAPISTATUS emsabp_get_CreationTemplatesTable ( TALLOC_CTX *  mem_ctx,
struct emsabp_context emsabp_ctx,
uint32_t  dwFlags,
struct PropertyRowSet_r **  SRowSet 
)

Retrieve and build the CreationTemplates Table requested by GetSpecialTable NSPI call

Parameters:
mem_ctx pointer to the memory context
emsabp_ctx pointer to the EMSABP context
dwFlags flags controlling whether strings should be UNICODE or not
SRowSet pointer on pointer to the output SRowSet array
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI_E_CORRUPT_STORE

Referenced by dcesrv_NspiGetSpecialTable().

_PUBLIC_ enum MAPISTATUS emsabp_get_HierarchyTable ( TALLOC_CTX *  mem_ctx,
struct emsabp_context emsabp_ctx,
uint32_t  dwFlags,
struct PropertyRowSet_r **  SRowSet 
)

Retrieve and build the HierarchyTable requested by GetSpecialTable NSPI call

Parameters:
mem_ctx pointer to the memory context
emsabp_ctx pointer to the EMSABP context
dwFlags flags controlling whether strings should be UNICODE or not
SRowSet pointer on pointer to the output SRowSet array
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI_E_CORRUPT_STORE

References PermanentEntryID::dn, emsabp_set_PermanentEntryID(), emsabp_table_fetch_attrs(), emsabp_context::mem_ctx, and emsabp_context::samdb_ctx.

Referenced by dcesrv_NspiGetSpecialTable().

_PUBLIC_ struct emsabp_context* emsabp_init ( struct loadparm_context *  lp_ctx,
TDB_CONTEXT *  tdb_ctx 
) [read]

Initialize the EMSABP context and open connections to Samba databases.

Parameters:
lp_ctx pointer to the loadparm context
tdb_ctx pointer to the EMSABP TDB context
Returns:
Allocated emsabp_context on success, otherwise NULL

References emsabp_tdb_init_tmp(), emsabp_context::lp_ctx, emsabp_context::mem_ctx, samdb_connect(), emsabp_context::samdb_ctx, emsabp_context::tdb_ctx, and emsabp_context::ttdb_ctx.

Referenced by dcesrv_NspiBind().

_PUBLIC_ enum MAPISTATUS emsabp_PermanentEntryID_to_Binary_r ( TALLOC_CTX *  mem_ctx,
struct PermanentEntryID permEntryID,
struct Binary_r *  bin 
)

Map a PermanentEntryID structure into a Binary_r structure (for PR_ENTRYID and PR_EMS_AB_PARENT_ENTRYID properties)

Parameters:
mem_ctx pointer to the memory context
permEntryID pointer to the Permanent EntryID structure
bin pointer to the Binary_r structure the server will return
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI_E_INVALID_PARAMETER

References PermanentEntryID::DisplayType, PermanentEntryID::dn, PermanentEntryID::ID_type, PermanentEntryID::ProviderUID, PermanentEntryID::R1, PermanentEntryID::R2, PermanentEntryID::R3, and PermanentEntryID::R4.

Referenced by emsabp_query(), and emsabp_table_fetch_attrs().

_PUBLIC_ void* emsabp_query ( TALLOC_CTX *  mem_ctx,
struct emsabp_context emsabp_ctx,
struct ldb_message *  msg,
uint32_t  ulPropTag,
uint32_t  MId,
uint32_t  dwFlags 
)

Find the attribute matching the specified property tag and return the associated data.

Parameters:
mem_ctx pointer to the memory context
emsabp_ctx pointer to the EMSABP context
msg pointer to the LDB message
ulPropTag the property tag to lookup
MId Minimal Entry ID associated to the current message
dwFlags bit flags specifying whether or not the server must return the values of the property PidTagEntryId in the Ephemeral or Permanent Entry ID format
Note:
This implementation is at the moment limited to MAILUSER, which means we arbitrary set PR_OBJECT_TYPE and PR_DISPLAY_TYPE while we should have a generic method to fill these properties.
Returns:
Valid generic pointer on success, otherwise NULL

References EMSABP_ADDRTYPE, emsabp_EphemeralEntryID_to_Binary_r(), emsabp_PermanentEntryID_to_Binary_r(), emsabp_property_get_attribute(), emsabp_property_get_ref_attr(), emsabp_property_is_ref(), emsabp_search_dn(), emsabp_set_EphemeralEntryID(), and emsabp_set_PermanentEntryID().

Referenced by emsabp_fetch_attrs(), and emsabp_fetch_attrs_from_msg().

_PUBLIC_ enum MAPISTATUS emsabp_search ( TALLOC_CTX *  mem_ctx,
struct emsabp_context emsabp_ctx,
struct PropertyTagArray_r *  MIds,
struct Restriction_r *  restriction,
struct STAT *  pStat,
uint32_t  limit 
)

Search Active Directory given input search criterias. The function associates for each records returned by the search a unique session Minimal Entry ID and a LDB message.

Parameters:
mem_ctx pointer to the memory context
emsabp_ctx pointer to the EMSABP context
MIds pointer to the list of MIds the function returns
restriction pointer to restriction rules to apply to the search
pStat pointer the STAT structure associated to the search
limit the limit number of results the function can return
Note:
SortTypePhoneticDisplayName sort type is currently not supported.
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI error

References emsabp_property_get_attribute(), emsabp_tdb_fetch_MId(), emsabp_tdb_insert(), emsabp_tdb_lookup_MId(), emsabp_context::samdb_ctx, emsabp_context::tdb_ctx, and emsabp_context::ttdb_ctx.

Referenced by dcesrv_NspiGetMatches(), dcesrv_NspiSeekEntries(), and dcesrv_NspiUpdateStat().

_PUBLIC_ enum MAPISTATUS emsabp_search_dn ( struct emsabp_context emsabp_ctx,
const char *  dn,
struct ldb_message **  ldb_res 
)

Search for a given DN within AD and return the associated LDB message.

Parameters:
emsabp_ctx pointer to the EMSABP context
dn pointer to the DN string to search for
ldb_res pointer on pointer to the LDB message returned by the function
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI error

References emsabp_context::mem_ctx, and emsabp_context::samdb_ctx.

Referenced by emsabp_ab_container_by_id(), and emsabp_query().

_PUBLIC_ enum MAPISTATUS emsabp_search_legacyExchangeDN ( struct emsabp_context emsabp_ctx,
const char *  legacyDN,
struct ldb_message **  ldb_res,
bool *  pbUseConfPartition 
)

Search for a given AD record given its legacyDN parameter and return the associated LDB message.

Parameters:
emsabp_ctx pointer to the EMSABP context
legacyDN pointer to the legacyDN attribute value to lookup
ldb_res pointer on pointer to the LDB message returned by the function
pbUseConfPartition pointer on boolean specifying whether the legacyExchangeDN was retrieved from the Configuration parition or not
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI error

References emsabp_context::mem_ctx, and emsabp_context::samdb_ctx.

Referenced by dcesrv_NspiDNToMId().

_PUBLIC_ enum MAPISTATUS emsabp_set_EphemeralEntryID ( struct emsabp_context emsabp_ctx,
uint32_t  DisplayType,
uint32_t  MId,
struct EphemeralEntryID ephEntryID 
)

Build an EphemeralEntryID structure

Parameters:
emsabp_ctx pointer to the EMSABP context
DisplayType the AB object display type
MId the MId value
ephEntryID pointer to the EphemeralEntryID returned by the function
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI_E_NOT_ENOUGH_RESOURCES or MAPI_E_CORRUPT_STORE

References EphemeralEntryID::DisplayType, EphemeralEntryID::ID_type, EphemeralEntryID::MId, EphemeralEntryID::ProviderUID, EphemeralEntryID::R1, EphemeralEntryID::R2, EphemeralEntryID::R3, EphemeralEntryID::R4, emsabp_context::samdb_ctx, and samdb_ntds_objectGUID().

Referenced by emsabp_query().

_PUBLIC_ enum MAPISTATUS emsabp_set_PermanentEntryID ( struct emsabp_context emsabp_ctx,
uint32_t  DisplayType,
struct ldb_message *  msg,
struct PermanentEntryID permEntryID 
)

Build a PermanentEntryID structure

Parameters:
emsabp_ctx pointer to the EMSABP context
DisplayType the AB object display type
msg pointer to the LDB message
permEntryID pointer to the PermanentEntryID returned by the function
Note:
This function only covers DT_CONTAINER AddressBook objects. It should be extended in the future to support more containers.
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI_E_NOT_ENOUGH_RESOURCES or MAPI_E_CORRUPT_STORE

References PermanentEntryID::DisplayType, PermanentEntryID::dn, EMSABP_DN, GUID_NSPI, PermanentEntryID::ID_type, emsabp_context::mem_ctx, PermanentEntryID::ProviderUID, PermanentEntryID::R1, PermanentEntryID::R2, PermanentEntryID::R3, and PermanentEntryID::R4.

Referenced by emsabp_get_HierarchyTable(), and emsabp_query().

_PUBLIC_ enum MAPISTATUS emsabp_table_fetch_attrs ( TALLOC_CTX *  mem_ctx,
struct emsabp_context emsabp_ctx,
struct PropertyRow_r *  aRow,
uint32_t  dwFlags,
struct PermanentEntryID permEntryID,
struct PermanentEntryID parentPermEntryID,
struct ldb_message *  msg,
bool  child 
)

Builds the SRow array entry for the specified table record.

Parameters:
mem_ctx pointer to the memory context
emsabp_ctx pointer to the EMSABP context
aRow pointer to the SRow structure where results will be stored
dwFlags flags controlling whether strings should be unicode encoded or not
permEntryID pointer to the current record Permanent EntryID
parentPermEntryID pointer to the parent record Permanent EntryID
msg pointer to the LDB message for current record
child boolean value specifying whether current record is root or child within containers hierarchy
Returns:
MAPI_E_SUCCESS on success, otherwise MAPI error

References AB_RECIPIENTS, AB_SUBCONTAINERS, AB_UNMODIFIABLE, emsabp_PermanentEntryID_to_Binary_r(), emsabp_tdb_fetch_MId(), emsabp_tdb_insert(), and emsabp_context::tdb_ctx.

Referenced by emsabp_get_HierarchyTable().

_PUBLIC_ bool emsabp_verify_codepage ( struct emsabp_context emsabp_ctx,
uint32_t  CodePage 
)

Check if the provided codepage is correct

Parameters:
emsabp_ctx pointer to the EMSABP context
CodePage the codepage identifier
Note:
The prototype is currently incorrect, but we are looking for a better way to check codepage, maybe within AD. At the moment this function is just a wrapper over libmapi valid_codepage function.
Returns:
true on success, otherwise false

Referenced by dcesrv_NspiBind().

_PUBLIC_ bool emsabp_verify_user ( struct dcesrv_call_state *  dce_call,
struct emsabp_context emsabp_ctx 
)

Check if the authenticated user belongs to the Exchange organization

Parameters:
dce_call pointer to the session context
emsabp_ctx pointer to the EMSABP context
Returns:
true on success, otherwise false

References emsabp_context::account_name, emsabp_get_account_info(), and emsabp_context::mem_ctx.

Referenced by dcesrv_NspiBind().


Creative Commons License
Creative Commons Attribution icon Creative Commons Share Alike icon
This content is licensed under the Creative Commons
Attribution ShareAlike License v. 3.0:
http://creativecommons.org/licenses/by-sa/3.0/