#ifndef DB_OD_H
#define DB_OD_H
#include <uuid/uuid.h>
#include <OpenDirectory/OpenDirectory.h>
#include <OpenDirectory/OpenDirectoryPriv.h>
#include <DirectoryService/DirServicesConst.h>
#define OD_USER_CACHE_KEY "%u"
#define OD_DEFAULT_USERNAME_FORMAT "%u"
#define OD_DEFAULT_PASS_SCHEME "CRYPT"
#define kCRAM_MD5_AuthSuccess "k-cram-md5-auth-success"
#define kCRAM_MD5_AuthFailed "k-cram-md5-auth-failed"
#define kCRAM_APOP_AuthSuccess "k-apop-auth-success"
#define kCRAM_APOP_AuthFailed "k-apop-auth-failed"
#define kXMLKeyAttrVersion "kAttributeVersion"
#define kXMLValueVersion "Apple Mail 1.0"
#define kXMLValueVersion2 "Apple Mail 2.0"
#define kXMLKeyAcctState "kMailAccountState"
#define kXMLValueAcctEnabled "Enabled"
#define kXMLValueAcctDisabled "Off"
#define kXMLValueAcctFwd "Forward"
#define kXMLKeyAutoFwd "kAutoForwardValue"
#define kXMLKeyMigrationFlag "kMigrationFlag"
#define kXMLValueAcctMigrated "AcctMigrated"
#define kXMLValueAcctNotMigrated "AcctNotMigrated"
#define kXMLKeykIMAPLoginState "kIMAPLoginState"
#define kXMLValueIMAPLoginOK "IMAPAllowed"
#define kXMLValueIMAPLogInNotOK "IMAPDeny"
#define kXMLKeyPOP3LoginState "kPOP3LoginState"
#define kXMLValuePOP3LoginOK "POP3Allowed"
#define kXMLValuePOP3LoginNotOK "POP3Deny"
#define kXMLKeyAcctLoc "kMailAccountLocation"
#define kXMLKeyAltDataStoreLoc "kAltMailStoreLoc"
#define kXMLKeyDiskQuota "kUserDiskQuota"
#define kPushNotifyEnabled "notification_server_enabled"
extern int od_pos_cache_ttl;
extern int od_neg_cache_ttl;
extern bool od_use_getpwnam_ext;
typedef enum {
unknown_state = 0x00000000,
unknown_user = 0x00000001,
account_enabled = 0x00000002,
imap_enabled = 0x00000004,
pop_enabled = 0x00000008,
auto_fwd_enabled = 0x00000010,
sacl_enabled = 0x00000020,
sacl_not_member = 0x00000040,
acct_migrated = 0x00000080
} od_acct_state;
typedef enum {
OD_AUTH_SUCCESS,
OD_AUTH_FAILURE
} od_auth_event_t;
struct od_user {
int refcount;
time_t create_time;
uid_t user_uid;
gid_t user_gid;
od_acct_state acct_state;
int mail_quota;
char *user_guid;
char *record_name;
char *acct_loc;
char *alt_data_loc;
};
struct db_od {
int refcount;
ODSessionRef od_session_ref;
ODNodeRef od_node_ref;
unsigned int userdb:1;
int pos_cache_ttl;
int neg_cache_ttl;
bool use_getpwnam_ext;
struct hash_table *users_table;
};
typedef struct msg_data_s {
unsigned long msg;
unsigned long pid;
char d1[128];
char d2[512];
char d3[512];
char d4[512];
} msg_data_t;
void send_server_event ( struct auth_request *in_request, const od_auth_event_t in_event_code, const char *in_user, const char *in_addr );
void close_server_event_port ( void );
struct od_user *db_od_user_lookup ( struct auth_request *in_request, struct db_od *in_db, const char *in_user_name, bool in_is_auth );
struct db_od *db_od_init ( bool in_userdb );
void db_od_user_unref ( struct od_user **in_user_info );
void db_od_do_init ( struct db_od *in_od_info );
void db_od_unref ( struct db_od **in_od_info_p );
void db_od_sacl_check ( struct auth_request *in_request, struct od_user *in_od_user, const char *in_group );
const char *db_od_get_ms_path ( struct auth_request *in_request, const char *in_tag, const char *in_partition_map );
void db_od_print_cf_error( struct auth_request *in_request, CFErrorRef in_cf_err_ref, const char *in_default_str );
bool is_acct_enabled ( struct auth_request *in_request, od_acct_state in_acct_state, const char *in_user );
void push_notify_init ( struct od_user *in_user_info );
#endif