s3: only use netlogon/nbt header when needed.
[metze/samba/wip.git] / source3 / include / proto.h
index 75267f820fc66166b1e40b3a11cd82d44fb4851d..ee6f09a72923314dd1826d143835e894b4445c46 100644 (file)
@@ -121,7 +121,7 @@ NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
                                    uid_t *uid, gid_t *gid,
                                    char **found_username,
                                    struct nt_user_token **token);
-bool user_in_group_sid(const char *username, const DOM_SID *group_sid);
+bool user_in_group_sid(const char *username, const struct dom_sid *group_sid);
 bool user_in_group(const char *username, const char *groupname);
 NTSTATUS make_server_info_pw(struct auth_serversupplied_info **server_info,
                              char *unix_username,
@@ -133,10 +133,13 @@ NTSTATUS make_serverinfo_from_username(TALLOC_CTX *mem_ctx,
 struct auth_serversupplied_info *copy_serverinfo(TALLOC_CTX *mem_ctx,
                                                 const struct auth_serversupplied_info *src);
 bool init_guest_info(void);
+bool init_system_info(void);
 bool server_info_set_session_key(struct auth_serversupplied_info *info,
                                 DATA_BLOB session_key);
 NTSTATUS make_server_info_guest(TALLOC_CTX *mem_ctx,
                                struct auth_serversupplied_info **server_info);
+NTSTATUS make_server_info_system(TALLOC_CTX *mem_ctx,
+                                struct auth_serversupplied_info **server_info);
 bool copy_current_user(struct current_user *dst, struct current_user *src);
 struct passwd *smb_getpwnam( TALLOC_CTX *mem_ctx, char *domuser,
                             fstring save_username, bool create );
@@ -177,6 +180,26 @@ NTSTATUS auth_winbind_init(void);
 /* The following definitions come from auth/server_info.c  */
 
 struct auth_serversupplied_info *make_server_info(TALLOC_CTX *mem_ctx);
+NTSTATUS serverinfo_to_SamInfo2(struct auth_serversupplied_info *server_info,
+                               uint8_t *pipe_session_key,
+                               size_t pipe_session_key_len,
+                               struct netr_SamInfo2 *sam2);
+NTSTATUS serverinfo_to_SamInfo3(struct auth_serversupplied_info *server_info,
+                               uint8_t *pipe_session_key,
+                               size_t pipe_session_key_len,
+                               struct netr_SamInfo3 *sam3);
+NTSTATUS serverinfo_to_SamInfo6(struct auth_serversupplied_info *server_info,
+                               uint8_t *pipe_session_key,
+                               size_t pipe_session_key_len,
+                               struct netr_SamInfo6 *sam6);
+NTSTATUS samu_to_SamInfo3(TALLOC_CTX *mem_ctx,
+                         struct samu *samu,
+                         const char *login_server,
+                         struct netr_SamInfo3 **_info3);
+struct netr_SamInfo3 *copy_netr_SamInfo3(TALLOC_CTX *mem_ctx,
+                                        struct netr_SamInfo3 *orig);
+struct netr_SamInfo3 *wbcAuthUserInfo_to_netr_SamInfo3(TALLOC_CTX *mem_ctx,
+                                       const struct wbcAuthUserInfo *info);
 
 /* The following definitions come from auth/auth_wbc.c  */
 
@@ -201,18 +224,18 @@ NTSTATUS pass_check(const struct passwd *pass, const char *user, const char *pas
 
 /* The following definitions come from auth/token_util.c  */
 
-bool nt_token_check_sid ( const DOM_SID *sid, const NT_USER_TOKEN *token );
+bool nt_token_check_sid ( const struct dom_sid *sid, const NT_USER_TOKEN *token );
 bool nt_token_check_domain_rid( NT_USER_TOKEN *token, uint32 rid );
 NT_USER_TOKEN *get_root_nt_token( void );
-NTSTATUS add_aliases(const DOM_SID *domain_sid,
+NTSTATUS add_aliases(const struct dom_sid *domain_sid,
                     struct nt_user_token *token);
-NTSTATUS create_builtin_users(const DOM_SID *sid);
-NTSTATUS create_builtin_administrators(const DOM_SID *sid);
+NTSTATUS create_builtin_users(const struct dom_sid *sid);
+NTSTATUS create_builtin_administrators(const struct dom_sid *sid);
 struct nt_user_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
-                                           const DOM_SID *user_sid,
+                                           const struct dom_sid *user_sid,
                                            bool is_guest,
                                            int num_groupsids,
-                                           const DOM_SID *groupsids);
+                                           const struct dom_sid *groupsids);
 void debug_nt_user_token(int dbg_class, int dbg_lev, NT_USER_TOKEN *token);
 void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
                           int n_groups, gid_t *groups);
@@ -220,14 +243,14 @@ void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
 /* The following definitions come from groupdb/mapping.c  */
 
 NTSTATUS add_initial_entry(gid_t gid, const char *sid, enum lsa_SidType sid_name_use, const char *nt_name, const char *comment);
-bool get_domain_group_from_sid(DOM_SID sid, GROUP_MAP *map);
+bool get_domain_group_from_sid(struct dom_sid sid, GROUP_MAP *map);
 int smb_create_group(const char *unix_group, gid_t *new_gid);
 int smb_delete_group(const char *unix_group);
 int smb_set_primary_group(const char *unix_group, const char* unix_user);
 int smb_add_user_group(const char *unix_group, const char *unix_user);
 int smb_delete_user_group(const char *unix_group, const char *unix_user);
 NTSTATUS pdb_default_getgrsid(struct pdb_methods *methods, GROUP_MAP *map,
-                                DOM_SID sid);
+                                struct dom_sid sid);
 NTSTATUS pdb_default_getgrgid(struct pdb_methods *methods, GROUP_MAP *map,
                                 gid_t gid);
 NTSTATUS pdb_default_getgrnam(struct pdb_methods *methods, GROUP_MAP *map,
@@ -237,38 +260,38 @@ NTSTATUS pdb_default_add_group_mapping_entry(struct pdb_methods *methods,
 NTSTATUS pdb_default_update_group_mapping_entry(struct pdb_methods *methods,
                                                   GROUP_MAP *map);
 NTSTATUS pdb_default_delete_group_mapping_entry(struct pdb_methods *methods,
-                                                  DOM_SID sid);
+                                                  struct dom_sid sid);
 NTSTATUS pdb_default_enum_group_mapping(struct pdb_methods *methods,
-                                          const DOM_SID *sid, enum lsa_SidType sid_name_use,
+                                          const struct dom_sid *sid, enum lsa_SidType sid_name_use,
                                           GROUP_MAP **pp_rmap, size_t *p_num_entries,
                                           bool unix_only);
 NTSTATUS pdb_default_create_alias(struct pdb_methods *methods,
                                  const char *name, uint32 *rid);
 NTSTATUS pdb_default_delete_alias(struct pdb_methods *methods,
-                                 const DOM_SID *sid);
+                                 const struct dom_sid *sid);
 NTSTATUS pdb_default_get_aliasinfo(struct pdb_methods *methods,
-                                  const DOM_SID *sid,
+                                  const struct dom_sid *sid,
                                   struct acct_info *info);
 NTSTATUS pdb_default_set_aliasinfo(struct pdb_methods *methods,
-                                  const DOM_SID *sid,
+                                  const struct dom_sid *sid,
                                   struct acct_info *info);
 NTSTATUS pdb_default_add_aliasmem(struct pdb_methods *methods,
-                                 const DOM_SID *alias, const DOM_SID *member);
+                                 const struct dom_sid *alias, const struct dom_sid *member);
 NTSTATUS pdb_default_del_aliasmem(struct pdb_methods *methods,
-                                 const DOM_SID *alias, const DOM_SID *member);
+                                 const struct dom_sid *alias, const struct dom_sid *member);
 NTSTATUS pdb_default_enum_aliasmem(struct pdb_methods *methods,
-                                  const DOM_SID *alias, TALLOC_CTX *mem_ctx,
-                                  DOM_SID **pp_members,
+                                  const struct dom_sid *alias, TALLOC_CTX *mem_ctx,
+                                  struct dom_sid **pp_members,
                                   size_t *p_num_members);
 NTSTATUS pdb_default_alias_memberships(struct pdb_methods *methods,
                                       TALLOC_CTX *mem_ctx,
-                                      const DOM_SID *domain_sid,
-                                      const DOM_SID *members,
+                                      const struct dom_sid *domain_sid,
+                                      const struct dom_sid *members,
                                       size_t num_members,
                                       uint32 **pp_alias_rids,
                                       size_t *p_num_alias_rids);
 NTSTATUS pdb_nop_getgrsid(struct pdb_methods *methods, GROUP_MAP *map,
-                                DOM_SID sid);
+                                struct dom_sid sid);
 NTSTATUS pdb_nop_getgrgid(struct pdb_methods *methods, GROUP_MAP *map,
                                 gid_t gid);
 NTSTATUS pdb_nop_getgrnam(struct pdb_methods *methods, GROUP_MAP *map,
@@ -278,13 +301,13 @@ NTSTATUS pdb_nop_add_group_mapping_entry(struct pdb_methods *methods,
 NTSTATUS pdb_nop_update_group_mapping_entry(struct pdb_methods *methods,
                                                   GROUP_MAP *map);
 NTSTATUS pdb_nop_delete_group_mapping_entry(struct pdb_methods *methods,
-                                                  DOM_SID sid);
+                                                  struct dom_sid sid);
 NTSTATUS pdb_nop_enum_group_mapping(struct pdb_methods *methods,
                                           enum lsa_SidType sid_name_use,
                                           GROUP_MAP **rmap, size_t *num_entries,
                                           bool unix_only);
-bool pdb_get_dom_grp_info(const DOM_SID *sid, struct acct_info *info);
-bool pdb_set_dom_grp_info(const DOM_SID *sid, const struct acct_info *info);
+bool pdb_get_dom_grp_info(const struct dom_sid *sid, struct acct_info *info);
+bool pdb_set_dom_grp_info(const struct dom_sid *sid, const struct acct_info *info);
 NTSTATUS pdb_create_builtin_alias(uint32 rid);
 
 /* The following definitions come from groupdb/mapping_ldb.c  */
@@ -523,10 +546,10 @@ bool dbghdr(int level, const char *location, const char *func);
 char *get_sec_mask_str(TALLOC_CTX *ctx, uint32 type);
 void display_sec_access(uint32_t *info);
 void display_sec_ace_flags(uint8_t flags);
-void display_sec_ace(SEC_ACE *ace);
-void display_sec_acl(SEC_ACL *sec_acl);
+void display_sec_ace(struct security_ace *ace);
+void display_sec_acl(struct security_acl *sec_acl);
 void display_acl_type(uint16 type);
-void display_sec_desc(SEC_DESC *sec);
+void display_sec_desc(struct security_descriptor *sec);
 
 /* The following definitions come from lib/dmallocmsg.c  */
 
@@ -631,23 +654,23 @@ void popt_common_set_auth_info(struct user_auth_info *auth_info);
 
 /* The following definitions come from lib/privileges.c  */
 
-bool get_privileges_for_sids(SE_PRIV *privileges, DOM_SID *slist, int scount);
-NTSTATUS privilege_enumerate_accounts(DOM_SID **sids, int *num_sids);
+bool get_privileges_for_sids(SE_PRIV *privileges, struct dom_sid *slist, int scount);
+NTSTATUS privilege_enumerate_accounts(struct dom_sid **sids, int *num_sids);
 NTSTATUS privilege_enum_sids(const SE_PRIV *mask, TALLOC_CTX *mem_ctx,
-                            DOM_SID **sids, int *num_sids);
-bool grant_privilege(const DOM_SID *sid, const SE_PRIV *priv_mask);
-bool grant_privilege_by_name(DOM_SID *sid, const char *name);
-bool revoke_privilege(const DOM_SID *sid, const SE_PRIV *priv_mask);
-bool revoke_all_privileges( DOM_SID *sid );
-bool revoke_privilege_by_name(DOM_SID *sid, const char *name);
-NTSTATUS privilege_create_account(const DOM_SID *sid );
+                            struct dom_sid **sids, int *num_sids);
+bool grant_privilege(const struct dom_sid *sid, const SE_PRIV *priv_mask);
+bool grant_privilege_by_name(struct dom_sid *sid, const char *name);
+bool revoke_privilege(const struct dom_sid *sid, const SE_PRIV *priv_mask);
+bool revoke_all_privileges( struct dom_sid *sid );
+bool revoke_privilege_by_name(struct dom_sid *sid, const char *name);
+NTSTATUS privilege_create_account(const struct dom_sid *sid );
 NTSTATUS privilege_delete_account(const struct dom_sid *sid);
 NTSTATUS privilege_set_init(PRIVILEGE_SET *priv_set);
 NTSTATUS privilege_set_init_by_ctx(TALLOC_CTX *mem_ctx, PRIVILEGE_SET *priv_set);
 void privilege_set_free(PRIVILEGE_SET *priv_set);
 NTSTATUS dup_luid_attr(TALLOC_CTX *mem_ctx, LUID_ATTR **new_la, LUID_ATTR *old_la, int count);
-bool is_privileged_sid( const DOM_SID *sid );
-bool grant_all_privileges( const DOM_SID *sid );
+bool is_privileged_sid( const struct dom_sid *sid );
+bool grant_all_privileges( const struct dom_sid *sid );
 
 /* The following definitions come from lib/privileges_basic.c  */
 
@@ -692,15 +715,15 @@ ssize_t drain_socket(int sockfd, size_t count);
 
 /* The following definitions come from lib/secdesc.c  */
 
-uint32_t get_sec_info(const SEC_DESC *sd);
-SEC_DESC *sec_desc_merge(TALLOC_CTX *ctx, SEC_DESC *new_sdb, SEC_DESC *old_sdb);
-SEC_DESC_BUF *sec_desc_merge_buf(TALLOC_CTX *ctx, SEC_DESC_BUF *new_sdb, SEC_DESC_BUF *old_sdb);
-SEC_DESC *make_sec_desc(TALLOC_CTX *ctx,
+uint32_t get_sec_info(const struct security_descriptor *sd);
+struct security_descriptor *sec_desc_merge(TALLOC_CTX *ctx, struct security_descriptor *new_sdb, struct security_descriptor *old_sdb);
+struct sec_desc_buf *sec_desc_merge_buf(TALLOC_CTX *ctx, struct sec_desc_buf *new_sdb, struct sec_desc_buf *old_sdb);
+struct security_descriptor *make_sec_desc(TALLOC_CTX *ctx,
                        enum security_descriptor_revision revision,
                        uint16 type,
-                       const DOM_SID *owner_sid, const DOM_SID *grp_sid,
-                       SEC_ACL *sacl, SEC_ACL *dacl, size_t *sd_size);
-SEC_DESC *dup_sec_desc(TALLOC_CTX *ctx, const SEC_DESC *src);
+                       const struct dom_sid *owner_sid, const struct dom_sid *grp_sid,
+                       struct security_acl *sacl, struct security_acl *dacl, size_t *sd_size);
+struct security_descriptor *dup_sec_desc(TALLOC_CTX *ctx, const struct security_descriptor *src);
 NTSTATUS marshall_sec_desc(TALLOC_CTX *mem_ctx,
                           struct security_descriptor *secdesc,
                           uint8 **data, size_t *len);
@@ -711,24 +734,24 @@ NTSTATUS unmarshall_sec_desc(TALLOC_CTX *mem_ctx, uint8 *data, size_t len,
                             struct security_descriptor **psecdesc);
 NTSTATUS unmarshall_sec_desc_buf(TALLOC_CTX *mem_ctx, uint8_t *data, size_t len,
                                 struct sec_desc_buf **psecdesc_buf);
-SEC_DESC *make_standard_sec_desc(TALLOC_CTX *ctx, const DOM_SID *owner_sid, const DOM_SID *grp_sid,
-                                SEC_ACL *dacl, size_t *sd_size);
-SEC_DESC_BUF *make_sec_desc_buf(TALLOC_CTX *ctx, size_t len, SEC_DESC *sec_desc);
-SEC_DESC_BUF *dup_sec_desc_buf(TALLOC_CTX *ctx, SEC_DESC_BUF *src);
-NTSTATUS sec_desc_add_sid(TALLOC_CTX *ctx, SEC_DESC **psd, DOM_SID *sid, uint32 mask, size_t *sd_size);
-NTSTATUS sec_desc_mod_sid(SEC_DESC *sd, DOM_SID *sid, uint32 mask);
-NTSTATUS sec_desc_del_sid(TALLOC_CTX *ctx, SEC_DESC **psd, DOM_SID *sid, size_t *sd_size);
-bool sd_has_inheritable_components(const SEC_DESC *parent_ctr, bool container);
+struct security_descriptor *make_standard_sec_desc(TALLOC_CTX *ctx, const struct dom_sid *owner_sid, const struct dom_sid *grp_sid,
+                                struct security_acl *dacl, size_t *sd_size);
+struct sec_desc_buf *make_sec_desc_buf(TALLOC_CTX *ctx, size_t len, struct security_descriptor *sec_desc);
+struct sec_desc_buf *dup_sec_desc_buf(TALLOC_CTX *ctx, struct sec_desc_buf *src);
+NTSTATUS sec_desc_add_sid(TALLOC_CTX *ctx, struct security_descriptor **psd, struct dom_sid *sid, uint32 mask, size_t *sd_size);
+NTSTATUS sec_desc_mod_sid(struct security_descriptor *sd, struct dom_sid *sid, uint32 mask);
+NTSTATUS sec_desc_del_sid(TALLOC_CTX *ctx, struct security_descriptor **psd, struct dom_sid *sid, size_t *sd_size);
+bool sd_has_inheritable_components(const struct security_descriptor *parent_ctr, bool container);
 NTSTATUS se_create_child_secdesc(TALLOC_CTX *ctx,
-                                        SEC_DESC **ppsd,
+                                        struct security_descriptor **ppsd,
                                        size_t *psize,
-                                        const SEC_DESC *parent_ctr,
-                                        const DOM_SID *owner_sid,
-                                        const DOM_SID *group_sid,
+                                        const struct security_descriptor *parent_ctr,
+                                        const struct dom_sid *owner_sid,
+                                        const struct dom_sid *group_sid,
                                         bool container);
 NTSTATUS se_create_child_secdesc_buf(TALLOC_CTX *ctx,
-                                       SEC_DESC_BUF **ppsdb,
-                                       const SEC_DESC *parent_ctr,
+                                       struct sec_desc_buf **ppsdb,
+                                       const struct security_descriptor *parent_ctr,
                                        bool container);
 
 /* The following definitions come from lib/select.c  */
@@ -749,14 +772,14 @@ struct named_mutex *grab_named_mutex(TALLOC_CTX *mem_ctx, const char *name,
 /* The following definitions come from lib/sharesec.c  */
 
 bool share_info_db_init(void);
-SEC_DESC *get_share_security_default( TALLOC_CTX *ctx, size_t *psize, uint32 def_access);
-SEC_DESC *get_share_security( TALLOC_CTX *ctx, const char *servicename,
+struct security_descriptor *get_share_security_default( TALLOC_CTX *ctx, size_t *psize, uint32 def_access);
+struct security_descriptor *get_share_security( TALLOC_CTX *ctx, const char *servicename,
                              size_t *psize);
-bool set_share_security(const char *share_name, SEC_DESC *psd);
+bool set_share_security(const char *share_name, struct security_descriptor *psd);
 bool delete_share_security(const char *servicename);
 bool share_access_check(const NT_USER_TOKEN *token, const char *sharename,
                        uint32 desired_access);
-bool parse_usershare_acl(TALLOC_CTX *ctx, const char *acl_str, SEC_DESC **ppsd);
+bool parse_usershare_acl(TALLOC_CTX *ctx, const char *acl_str, struct security_descriptor **ppsd);
 
 /* The following definitions come from lib/smbldap.c  */
 
@@ -1049,8 +1072,8 @@ void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_offset);
 time_t pull_dos_date(const uint8_t *date_ptr, int zone_offset);
 time_t pull_dos_date2(const uint8_t *date_ptr, int zone_offset);
 time_t pull_dos_date3(const uint8_t *date_ptr, int zone_offset);
-uint32 convert_time_t_to_uint32(time_t t);
-time_t convert_uint32_to_time_t(uint32 u);
+uint32_t convert_time_t_to_uint32_t(time_t t);
+time_t convert_uint32_t_to_time_t(uint32_t u);
 bool nt_time_is_zero(const NTTIME *nt);
 time_t generalized_to_unix_time(const char *str);
 int get_server_zone_offset(void);
@@ -1102,15 +1125,19 @@ bool nt_time_is_set(const NTTIME *nt);
 char *get_user_home_dir(TALLOC_CTX *mem_ctx, const char *user);
 struct passwd *Get_Pwnam_alloc(TALLOC_CTX *mem_ctx, const char *user);
 
+/* The following definitions come from lib/util_names.c  */
+void gfree_netbios_names(void);
+bool set_global_myname(const char *myname);
+const char *global_myname(void);
+bool set_global_myworkgroup(const char *myworkgroup);
+const char *lp_workgroup(void);
+const char *get_global_sam_name(void);
+
 /* The following definitions come from lib/util.c  */
 
 enum protocol_types get_Protocol(void);
 void set_Protocol(enum protocol_types  p);
 bool all_zero(const uint8_t *ptr, size_t size);
-bool set_global_myname(const char *myname);
-const char *global_myname(void);
-bool set_global_myworkgroup(const char *myworkgroup);
-const char *lp_workgroup(void);
 bool set_global_scope(const char *scope);
 const char *global_scope(void);
 void gfree_names(void);
@@ -1282,7 +1309,7 @@ NTSTATUS merge_nt_token(TALLOC_CTX *mem_ctx,
                        const struct nt_user_token *token_1,
                        const struct nt_user_token *token_2,
                        struct nt_user_token **token_out);
-bool token_sid_in_ace(const NT_USER_TOKEN *token, const SEC_ACE *ace);
+bool token_sid_in_ace(const NT_USER_TOKEN *token, const struct security_ace *ace);
 
 /* The following definitions come from lib/util_pw.c  */
 
@@ -1294,31 +1321,18 @@ struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid) ;
 /* The following definitions come from ..libcli/registry/util_reg.c  */
 
 const char *str_regtype(int type);
-bool push_reg_sz(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *ic,
-                DATA_BLOB *blob, const char *s);
-bool push_reg_multi_sz(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *ic,
-                      DATA_BLOB *blob, const char **a);
-bool pull_reg_sz(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *ic,
-                const DATA_BLOB *blob, const char **s);
-bool pull_reg_multi_sz(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *ic,
-                      const DATA_BLOB *blob, const char ***a);
-
-/* The following definitions come from lib/util_reg_api.c  */
-
-WERROR registry_pull_value(TALLOC_CTX *mem_ctx,
-                          struct registry_value **pvalue,
-                          enum winreg_Type type, uint8 *data,
-                          uint32 size, uint32 length);
-WERROR registry_push_value(TALLOC_CTX *mem_ctx,
-                          const struct registry_value *value,
-                          DATA_BLOB *presult);
+int regtype_by_string(const char *str);
+bool push_reg_sz(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char *s);
+bool push_reg_multi_sz(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char **a);
+bool pull_reg_sz(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, const char **s);
+bool pull_reg_multi_sz(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, const char ***a);
 
 /* The following definitions come from lib/util_seaccess.c  */
 
 void se_map_generic(uint32 *access_mask, const struct generic_mapping *mapping);
 void security_acl_map_generic(struct security_acl *sa, const struct generic_mapping *mapping);
 void se_map_standard(uint32 *access_mask, struct standard_mapping *mapping);
-NTSTATUS se_access_check(const SEC_DESC *sd, const NT_USER_TOKEN *token,
+NTSTATUS se_access_check(const struct security_descriptor *sd, const NT_USER_TOKEN *token,
                     uint32 acc_desired, uint32 *acc_granted);
 
 /* The following definitions come from lib/util_sec.c  */
@@ -1344,39 +1358,38 @@ bool is_setuid_root(void) ;
 
 const char *sid_type_lookup(uint32 sid_type) ;
 NT_USER_TOKEN *get_system_token(void) ;
-const char *get_global_sam_name(void) ;
-char *sid_to_fstring(fstring sidstr_out, const DOM_SID *sid);
-char *sid_string_talloc(TALLOC_CTX *mem_ctx, const DOM_SID *sid);
-char *sid_string_dbg(const DOM_SID *sid);
-char *sid_string_tos(const DOM_SID *sid);
-bool string_to_sid(DOM_SID *sidout, const char *sidstr);
-bool sid_append_rid(DOM_SID *sid, uint32 rid);
-bool sid_compose(DOM_SID *dst, const DOM_SID *domain_sid, uint32 rid);
-bool sid_split_rid(DOM_SID *sid, uint32 *rid);
-bool sid_peek_rid(const DOM_SID *sid, uint32 *rid);
-bool sid_peek_check_rid(const DOM_SID *exp_dom_sid, const DOM_SID *sid, uint32 *rid);
-void sid_copy(DOM_SID *dst, const DOM_SID *src);
-bool sid_linearize(char *outbuf, size_t len, const DOM_SID *sid);
-bool sid_parse(const char *inbuf, size_t len, DOM_SID *sid);
-int sid_compare(const DOM_SID *sid1, const DOM_SID *sid2);
-int sid_compare_domain(const DOM_SID *sid1, const DOM_SID *sid2);
-bool sid_equal(const DOM_SID *sid1, const DOM_SID *sid2);
-bool non_mappable_sid(DOM_SID *sid);
-char *sid_binstring(TALLOC_CTX *mem_ctx, const DOM_SID *sid);
-char *sid_binstring_hex(const DOM_SID *sid);
-DOM_SID *sid_dup_talloc(TALLOC_CTX *ctx, const DOM_SID *src);
-NTSTATUS add_sid_to_array(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
-                         DOM_SID **sids, size_t *num);
-NTSTATUS add_sid_to_array_unique(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
-                                DOM_SID **sids, size_t *num_sids);
-void del_sid_from_array(const DOM_SID *sid, DOM_SID **sids, size_t *num);
+char *sid_to_fstring(fstring sidstr_out, const struct dom_sid *sid);
+char *sid_string_talloc(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
+char *sid_string_dbg(const struct dom_sid *sid);
+char *sid_string_tos(const struct dom_sid *sid);
+bool string_to_sid(struct dom_sid *sidout, const char *sidstr);
+bool sid_append_rid(struct dom_sid *sid, uint32 rid);
+bool sid_compose(struct dom_sid *dst, const struct dom_sid *domain_sid, uint32 rid);
+bool sid_split_rid(struct dom_sid *sid, uint32 *rid);
+bool sid_peek_rid(const struct dom_sid *sid, uint32 *rid);
+bool sid_peek_check_rid(const struct dom_sid *exp_dom_sid, const struct dom_sid *sid, uint32 *rid);
+void sid_copy(struct dom_sid *dst, const struct dom_sid *src);
+bool sid_linearize(char *outbuf, size_t len, const struct dom_sid *sid);
+bool sid_parse(const char *inbuf, size_t len, struct dom_sid *sid);
+int sid_compare(const struct dom_sid *sid1, const struct dom_sid *sid2);
+int sid_compare_domain(const struct dom_sid *sid1, const struct dom_sid *sid2);
+bool sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2);
+bool non_mappable_sid(struct dom_sid *sid);
+char *sid_binstring(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
+char *sid_binstring_hex(const struct dom_sid *sid);
+struct dom_sid *sid_dup_talloc(TALLOC_CTX *ctx, const struct dom_sid *src);
+NTSTATUS add_sid_to_array(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
+                         struct dom_sid **sids, size_t *num);
+NTSTATUS add_sid_to_array_unique(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
+                                struct dom_sid **sids, size_t *num_sids);
+void del_sid_from_array(const struct dom_sid *sid, struct dom_sid **sids, size_t *num);
 bool add_rid_to_array_unique(TALLOC_CTX *mem_ctx,
                                    uint32 rid, uint32 **pp_rids, size_t *p_num);
-bool is_null_sid(const DOM_SID *sid);
-bool is_sid_in_token(const NT_USER_TOKEN *token, const DOM_SID *sid);
+bool is_null_sid(const struct dom_sid *sid);
+bool is_sid_in_token(const NT_USER_TOKEN *token, const struct dom_sid *sid);
 NTSTATUS sid_array_from_info3(TALLOC_CTX *mem_ctx,
                              const struct netr_SamInfo3 *info3,
-                             DOM_SID **user_sids,
+                             struct dom_sid **user_sids,
                              size_t *num_user_sids,
                              bool include_user_group_rid,
                              bool skip_ressource_groups);
@@ -1665,21 +1678,21 @@ const char *samba_version_string(void);
 
 /* The following definitions come from lib/winbind_util.c  */
 
-bool winbind_lookup_name(const char *dom_name, const char *name, DOM_SID *sid, 
+bool winbind_lookup_name(const char *dom_name, const char *name, struct dom_sid *sid,
                          enum lsa_SidType *name_type);
-bool winbind_lookup_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid, 
+bool winbind_lookup_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
                        const char **domain, const char **name,
                         enum lsa_SidType *name_type);
 bool winbind_ping(void);
-bool winbind_sid_to_uid(uid_t *puid, const DOM_SID *sid);
-bool winbind_uid_to_sid(DOM_SID *sid, uid_t uid);
-bool winbind_sid_to_gid(gid_t *pgid, const DOM_SID *sid);
-bool winbind_gid_to_sid(DOM_SID *sid, gid_t gid);
+bool winbind_sid_to_uid(uid_t *puid, const struct dom_sid *sid);
+bool winbind_uid_to_sid(struct dom_sid *sid, uid_t uid);
+bool winbind_sid_to_gid(gid_t *pgid, const struct dom_sid *sid);
+bool winbind_gid_to_sid(struct dom_sid *sid, gid_t gid);
 struct passwd * winbind_getpwnam(const char * sname);
-struct passwd * winbind_getpwsid(const DOM_SID *sid);
+struct passwd * winbind_getpwsid(const struct dom_sid *sid);
 wbcErr wb_is_trusted_domain(const char *domain);
 bool winbind_lookup_rids(TALLOC_CTX *mem_ctx,
-                        const DOM_SID *domain_sid,
+                        const struct dom_sid *domain_sid,
                         int num_rids, uint32 *rids,
                         const char **domain_name,
                         const char ***names, enum lsa_SidType **types);
@@ -1690,8 +1703,8 @@ bool winbind_get_groups(TALLOC_CTX *mem_ctx,
                        uint32_t *num_groups,
                        gid_t ** _groups);
 bool winbind_get_sid_aliases(TALLOC_CTX *mem_ctx,
-                            const DOM_SID *dom_sid,
-                            const DOM_SID *members,
+                            const struct dom_sid *dom_sid,
+                            const struct dom_sid *members,
                             size_t num_members,
                             uint32_t **pp_alias_rids,
                             size_t *p_num_alias_rids);
@@ -1726,6 +1739,7 @@ char *ads_build_domain(const char *dn);
 ADS_STRUCT *ads_init(const char *realm, 
                     const char *workgroup,
                     const char *ldap_server);
+bool ads_set_sasl_wrap_flags(ADS_STRUCT *ads, int flags);
 void ads_destroy(ADS_STRUCT **ads);
 
 const char *ads_get_ldap_server_name(ADS_STRUCT *ads);
@@ -1745,20 +1759,9 @@ NTSTATUS kerberos_return_pac(TALLOC_CTX *mem_ctx,
                             const char *impersonate_princ_s,
                             struct PAC_LOGON_INFO **logon_info);
 
-/* The following definitions come from libads/cldap.c  */
-bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx,
-                       const char *server,
-                       const char *realm,
-                       uint32_t nt_version,
-                       struct netlogon_samlogon_response **reply);
-bool ads_cldap_netlogon_5(TALLOC_CTX *mem_ctx,
-                         const char *server,
-                         const char *realm,
-                         struct NETLOGON_SAM_LOGON_RESPONSE_EX *reply5);
-
 /* The following definitions come from libads/disp_sec.c  */
 
-void ads_disp_sd(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, SEC_DESC *sd);
+void ads_disp_sd(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, struct security_descriptor *sd);
 
 /* The following definitions come from libads/dns.c  */
 
@@ -1821,7 +1824,8 @@ int kerberos_kinit_password(const char *principal,
 bool create_local_private_krb5_conf_for_domain(const char *realm,
                                                const char *domain,
                                                const char *sitename,
-                                               struct sockaddr_storage *pss);
+                                               struct sockaddr_storage *pss,
+                                               const char *kdc_name);
 
 /* The following definitions come from libads/kerberos_keytab.c  */
 
@@ -1895,7 +1899,7 @@ int ads_count_replies(ADS_STRUCT *ads, void *res);
 ADS_STATUS ads_USN(ADS_STRUCT *ads, uint32 *usn);
 ADS_STATUS ads_current_time(ADS_STRUCT *ads);
 ADS_STATUS ads_domain_func_level(ADS_STRUCT *ads, uint32 *val);
-ADS_STATUS ads_domain_sid(ADS_STRUCT *ads, DOM_SID *sid);
+ADS_STATUS ads_domain_sid(ADS_STRUCT *ads, struct dom_sid *sid);
 ADS_STATUS ads_site_dn(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const char **site_name);
 ADS_STATUS ads_site_dn_for_machine(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const char *computer_name, const char **site_dn);
 ADS_STATUS ads_upn_suffixes(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, char ***suffixes, size_t *num_suffixes);
@@ -1906,7 +1910,7 @@ ADS_STATUS ads_get_joinable_ous(ADS_STRUCT *ads,
 ADS_STATUS ads_get_sid_from_extended_dn(TALLOC_CTX *mem_ctx,
                                        const char *extended_dn,
                                        enum ads_extended_dn_flags flags,
-                                       DOM_SID *sid);
+                                       struct dom_sid *sid);
 char* ads_get_dnshostname( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name );
 char* ads_get_upn( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name );
 char* ads_get_samaccountname( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name );
@@ -2016,85 +2020,6 @@ ADS_STATUS ads_change_trust_account_password(ADS_STRUCT *ads, char *host_princip
 ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads,
                                       char **returned_principal);
 
-/* The following definitions come from libgpo/gpo_filesync.c  */
-
-NTSTATUS gpo_copy_file(TALLOC_CTX *mem_ctx,
-                      struct cli_state *cli,
-                      const char *nt_path,
-                      const char *unix_path);
-NTSTATUS gpo_sync_directories(TALLOC_CTX *mem_ctx,
-                             struct cli_state *cli,
-                             const char *nt_path,
-                             const char *local_path);
-
-/* The following definitions come from libgpo/gpo_ini.c  */
-
-NTSTATUS parse_gpt_ini(TALLOC_CTX *mem_ctx,
-                      const char *filename,
-                      uint32_t *version,
-                      char **display_name);
-
-/* The following definitions come from libgpo/gpo_reg.c  */
-
-struct nt_user_token *registry_create_system_token(TALLOC_CTX *mem_ctx);
-WERROR gp_init_reg_ctx(TALLOC_CTX *mem_ctx,
-                      const char *initial_path,
-                      uint32_t desired_access,
-                      const struct nt_user_token *token,
-                      struct gp_registry_context **reg_ctx);
-void gp_free_reg_ctx(struct gp_registry_context *reg_ctx);
-WERROR gp_store_reg_subkey(TALLOC_CTX *mem_ctx,
-                          const char *subkeyname,
-                          struct registry_key *curr_key,
-                          struct registry_key **new_key);
-WERROR gp_read_reg_subkey(TALLOC_CTX *mem_ctx,
-                         struct gp_registry_context *reg_ctx,
-                         const char *subkeyname,
-                         struct registry_key **key);
-WERROR gp_store_reg_val_sz(TALLOC_CTX *mem_ctx,
-                          struct registry_key *key,
-                          const char *val_name,
-                          const char *val);
-WERROR gp_read_reg_val_sz(TALLOC_CTX *mem_ctx,
-                         struct registry_key *key,
-                         const char *val_name,
-                         const char **val);
-WERROR gp_reg_state_store(TALLOC_CTX *mem_ctx,
-                         uint32_t flags,
-                         const char *dn,
-                         const struct nt_user_token *token,
-                         struct GROUP_POLICY_OBJECT *gpo_list);
-WERROR gp_reg_state_read(TALLOC_CTX *mem_ctx,
-                        uint32_t flags,
-                        const DOM_SID *sid,
-                        struct GROUP_POLICY_OBJECT **gpo_list);
-WERROR gp_secure_key(TALLOC_CTX *mem_ctx,
-                    uint32_t flags,
-                    struct registry_key *key,
-                    const DOM_SID *sid);
-void dump_reg_val(int lvl, const char *direction,
-                 const char *key, const char *subkey,
-                 struct registry_value *val);
-void dump_reg_entry(uint32_t flags,
-                   const char *dir,
-                   struct gp_registry_entry *entry);
-void dump_reg_entries(uint32_t flags,
-                     const char *dir,
-                     struct gp_registry_entry *entries,
-                     size_t num_entries);
-bool add_gp_registry_entry_to_array(TALLOC_CTX *mem_ctx,
-                                   struct gp_registry_entry *entry,
-                                   struct gp_registry_entry **entries,
-                                   size_t *num);
-WERROR reg_apply_registry_entry(TALLOC_CTX *mem_ctx,
-                               struct registry_key *root_key,
-                               struct gp_registry_context *reg_ctx,
-                               struct gp_registry_entry *entry,
-                               const struct nt_user_token *token,
-                               uint32_t flags);
-
-
-#include "librpc/gen_ndr/ndr_krb5pac.h"
 #include "librpc/gen_ndr/ndr_spoolss.h"
 
 /* The following definitions come from librpc/ndr/util.c  */
@@ -2240,20 +2165,6 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
                        const char *username,
                        const char *password,
                        const char *domain);
-/* The following definitions come from libsmb/clidgram.c  */
-
-bool send_getdc_request(TALLOC_CTX *mem_ctx,
-                       struct messaging_context *msg_ctx,
-                       struct sockaddr_storage *dc_ss,
-                       const char *domain_name,
-                       const DOM_SID *sid,
-                       uint32_t nt_version);
-bool receive_getdc_response(TALLOC_CTX *mem_ctx,
-                           struct sockaddr_storage *dc_ss,
-                           const char *domain_name,
-                           uint32_t *nt_version,
-                           const char **dc_name,
-                           struct netlogon_samlogon_response **reply);
 
 /* The following definitions come from libsmb/clientgen.c  */
 
@@ -2764,8 +2675,8 @@ bool cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUC
 bool cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST **pqt_list);
 bool cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt);
 bool cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt);
-void dump_ntquota(SMB_NTQUOTA_STRUCT *qt, bool _verbose, bool _numeric, void (*_sidtostring)(fstring str, DOM_SID *sid, bool _numeric));
-void dump_ntquota_list(SMB_NTQUOTA_LIST **qtl, bool _verbose, bool _numeric, void (*_sidtostring)(fstring str, DOM_SID *sid, bool _numeric));
+void dump_ntquota(SMB_NTQUOTA_STRUCT *qt, bool _verbose, bool _numeric, void (*_sidtostring)(fstring str, struct dom_sid *sid, bool _numeric));
+void dump_ntquota_list(SMB_NTQUOTA_LIST **qtl, bool _verbose, bool _numeric, void (*_sidtostring)(fstring str, struct dom_sid *sid, bool _numeric));
 
 /* The following definitions come from libsmb/clirap.c  */
 
@@ -2935,9 +2846,9 @@ NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
 
 /* The following definitions come from libsmb/clisecdesc.c  */
 
-SEC_DESC *cli_query_secdesc(struct cli_state *cli, uint16_t fnum, 
+struct security_descriptor *cli_query_secdesc(struct cli_state *cli, uint16_t fnum,
                            TALLOC_CTX *mem_ctx);
-bool cli_set_secdesc(struct cli_state *cli, uint16_t fnum, SEC_DESC *sd);
+bool cli_set_secdesc(struct cli_state *cli, uint16_t fnum, struct security_descriptor *sd);
 
 /* The following definitions come from libsmb/clispnego.c  */
 
@@ -3256,8 +3167,8 @@ bool netsamlogon_cache_init(void);
 bool netsamlogon_cache_shutdown(void);
 void netsamlogon_clear_cached_user(struct netr_SamInfo3 *info3);
 bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3);
-struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const DOM_SID *user_sid);
-bool netsamlogon_cache_have(const DOM_SID *user_sid);
+struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct dom_sid *user_sid);
+bool netsamlogon_cache_have(const struct dom_sid *user_sid);
 
 /* The following definitions come from libsmb/smb_seal.c  */
 
@@ -3319,9 +3230,9 @@ WERROR map_werror_from_unix(int error);
 
 bool trustdom_cache_enable(void);
 bool trustdom_cache_shutdown(void);
-bool trustdom_cache_store(char* name, char* alt_name, const DOM_SID *sid,
+bool trustdom_cache_store(char* name, char* alt_name, const struct dom_sid *sid,
                           time_t timeout);
-bool trustdom_cache_fetch(const char* name, DOM_SID* sid);
+bool trustdom_cache_fetch(const char* name, struct dom_sid* sid);
 uint32 trustdom_cache_fetch_timestamp( void );
 bool trustdom_cache_store_timestamp( uint32 t, time_t timeout );
 void trustdom_cache_flush(void);
@@ -3339,7 +3250,7 @@ NTSTATUS trust_pw_find_change_and_store_it(struct rpc_pipe_client *cli,
                                           const char *domain) ;
 bool enumerate_domain_trusts( TALLOC_CTX *mem_ctx, const char *domain,
                                      char ***domain_names, uint32 *num_domains,
-                                    DOM_SID **sids );
+                                    struct dom_sid **sids );
 
 /* The following definitions come from libsmb/unexpected.c  */
 
@@ -4326,7 +4237,7 @@ enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
                        char **pp_sharepath,
                        char **pp_comment,
                        char **pp_cp_share_name,
-                       SEC_DESC **ppsd,
+                       struct security_descriptor **ppsd,
                        bool *pallow_guest);
 int load_usershare_service(const char *servicename);
 int load_usershare_shares(void);
@@ -4411,31 +4322,31 @@ bool login_cache_delentry(const struct samu *sampass);
 bool lookup_name(TALLOC_CTX *mem_ctx,
                 const char *full_name, int flags,
                 const char **ret_domain, const char **ret_name,
-                DOM_SID *ret_sid, enum lsa_SidType *ret_type);
+                struct dom_sid *ret_sid, enum lsa_SidType *ret_type);
 bool lookup_name_smbconf(TALLOC_CTX *mem_ctx,
                 const char *full_name, int flags,
                 const char **ret_domain, const char **ret_name,
-                DOM_SID *ret_sid, enum lsa_SidType *ret_type);
+                struct dom_sid *ret_sid, enum lsa_SidType *ret_type);
 NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, int num_sids,
-                    const DOM_SID **sids, int level,
+                    const struct dom_sid **sids, int level,
                     struct lsa_dom_info **ret_domains,
                     struct lsa_name_info **ret_names);
-bool lookup_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
+bool lookup_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
                const char **ret_domain, const char **ret_name,
                enum lsa_SidType *ret_type);
-void store_uid_sid_cache(const DOM_SID *psid, uid_t uid);
-void store_gid_sid_cache(const DOM_SID *psid, gid_t gid);
-void uid_to_sid(DOM_SID *psid, uid_t uid);
-void gid_to_sid(DOM_SID *psid, gid_t gid);
-bool sid_to_uid(const DOM_SID *psid, uid_t *puid);
-bool sid_to_gid(const DOM_SID *psid, gid_t *pgid);
+void store_uid_sid_cache(const struct dom_sid *psid, uid_t uid);
+void store_gid_sid_cache(const struct dom_sid *psid, gid_t gid);
+void uid_to_sid(struct dom_sid *psid, uid_t uid);
+void gid_to_sid(struct dom_sid *psid, gid_t gid);
+bool sid_to_uid(const struct dom_sid *psid, uid_t *puid);
+bool sid_to_gid(const struct dom_sid *psid, gid_t *pgid);
 
 /* The following definitions come from passdb/machine_sid.c  */
 
-DOM_SID *get_global_sam_sid(void);
+struct dom_sid  *get_global_sam_sid(void);
 void reset_global_sam_sid(void) ;
-bool sid_check_is_domain(const DOM_SID *sid);
-bool sid_check_is_in_our_domain(const DOM_SID *sid);
+bool sid_check_is_domain(const struct dom_sid  *sid);
+bool sid_check_is_in_our_domain(const struct dom_sid  *sid);
 
 /* The following definitions come from passdb/passdb.c  */
 
@@ -4443,20 +4354,20 @@ const char *my_sam_name(void);
 struct samu *samu_new( TALLOC_CTX *ctx );
 NTSTATUS samu_set_unix(struct samu *user, const struct passwd *pwd);
 NTSTATUS samu_alloc_rid_unix(struct samu *user, const struct passwd *pwd);
-char *pdb_encode_acct_ctrl(uint32 acct_ctrl, size_t length);
-uint32 pdb_decode_acct_ctrl(const char *p);
-void pdb_sethexpwd(char p[33], const unsigned char *pwd, uint32 acct_ctrl);
+char *pdb_encode_acct_ctrl(uint32_t acct_ctrl, size_t length);
+uint32_t pdb_decode_acct_ctrl(const char *p);
+void pdb_sethexpwd(char p[33], const unsigned char *pwd, uint32_t acct_ctrl);
 bool pdb_gethexpwd(const char *p, unsigned char *pwd);
 void pdb_sethexhours(char *p, const unsigned char *hours);
 bool pdb_gethexhours(const char *p, unsigned char *hours);
 int algorithmic_rid_base(void);
-uid_t algorithmic_pdb_user_rid_to_uid(uint32 user_rid);
+uid_t algorithmic_pdb_user_rid_to_uid(uint32_t user_rid);
 uid_t max_algorithmic_uid(void);
-uint32 algorithmic_pdb_uid_to_user_rid(uid_t uid);
-gid_t pdb_group_rid_to_gid(uint32 group_rid);
+uint32_t algorithmic_pdb_uid_to_user_rid(uid_t uid);
+gid_t pdb_group_rid_to_gid(uint32_t group_rid);
 gid_t max_algorithmic_gid(void);
-uint32 algorithmic_pdb_gid_to_group_rid(gid_t gid);
-bool algorithmic_pdb_rid_is_user(uint32 rid);
+uint32_t algorithmic_pdb_gid_to_group_rid(gid_t gid);
+bool algorithmic_pdb_rid_is_user(uint32_t rid);
 bool lookup_global_sam_name(const char *name, int flags, uint32_t *rid,
                            enum lsa_SidType *type);
 NTSTATUS local_password_change(const char *user_name,
@@ -4465,8 +4376,8 @@ NTSTATUS local_password_change(const char *user_name,
                                char **pp_err_str,
                                char **pp_msg_str);
 bool init_samu_from_buffer(struct samu *sampass, uint32_t level,
-                          uint8 *buf, uint32 buflen);
-uint32 init_buffer_from_samu (uint8 **buf, struct samu *sampass, bool size_only);
+                          uint8_t *buf, uint32_t buflen);
+uint32_t init_buffer_from_samu (uint8_t **buf, struct samu *sampass, bool size_only);
 bool pdb_copy_sam_account(struct samu *dst, struct samu *src );
 bool pdb_update_bad_password_count(struct samu *sampass, bool *updated);
 bool pdb_update_autolock_flag(struct samu *sampass, bool *updated);
@@ -4475,21 +4386,20 @@ bool is_dc_trusted_domain_situation(const char *domain_name);
 bool get_trust_pw_clear(const char *domain, char **ret_pwd,
                        const char **account_name,
                        enum netr_SchannelType *channel);
-bool get_trust_pw_hash(const char *domain, uint8 ret_pwd[16],
+bool get_trust_pw_hash(const char *domain, uint8_t ret_pwd[16],
                       const char **account_name,
                       enum netr_SchannelType *channel);
-struct samr_LogonHours get_logon_hours_from_pdb(TALLOC_CTX *mem_ctx,
-                                               struct samu *pw);
+
 /* The following definitions come from passdb/pdb_compat.c  */
 
-uint32 pdb_get_user_rid (const struct samu *sampass);
-uint32 pdb_get_group_rid (struct samu *sampass);
-bool pdb_set_user_sid_from_rid (struct samu *sampass, uint32 rid, enum pdb_value_state flag);
-bool pdb_set_group_sid_from_rid (struct samu *sampass, uint32 grid, enum pdb_value_state flag);
+uint32_t pdb_get_user_rid (const struct samu *sampass);
+uint32_t pdb_get_group_rid (struct samu *sampass);
+bool pdb_set_user_sid_from_rid (struct samu *sampass, uint32_t rid, enum pdb_value_state flag);
+bool pdb_set_group_sid_from_rid (struct samu *sampass, uint32_t grid, enum pdb_value_state flag);
 
 /* The following definitions come from passdb/pdb_get_set.c  */
 
-uint32 pdb_get_acct_ctrl(const struct samu *sampass);
+uint32_t pdb_get_acct_ctrl(const struct samu *sampass);
 time_t pdb_get_logon_time(const struct samu *sampass);
 time_t pdb_get_logoff_time(const struct samu *sampass);
 time_t pdb_get_kickoff_time(const struct samu *sampass);
@@ -4499,15 +4409,15 @@ time_t pdb_get_pass_can_change_time(const struct samu *sampass);
 time_t pdb_get_pass_can_change_time_noncalc(const struct samu *sampass);
 time_t pdb_get_pass_must_change_time(const struct samu *sampass);
 bool pdb_get_pass_can_change(const struct samu *sampass);
-uint16 pdb_get_logon_divs(const struct samu *sampass);
-uint32 pdb_get_hours_len(const struct samu *sampass);
-const uint8 *pdb_get_hours(const struct samu *sampass);
-const uint8 *pdb_get_nt_passwd(const struct samu *sampass);
-const uint8 *pdb_get_lanman_passwd(const struct samu *sampass);
-const uint8 *pdb_get_pw_history(const struct samu *sampass, uint32 *current_hist_len);
+uint16_t pdb_get_logon_divs(const struct samu *sampass);
+uint32_t pdb_get_hours_len(const struct samu *sampass);
+const uint8_t *pdb_get_hours(const struct samu *sampass);
+const uint8_t *pdb_get_nt_passwd(const struct samu *sampass);
+const uint8_t *pdb_get_lanman_passwd(const struct samu *sampass);
+const uint8_t *pdb_get_pw_history(const struct samu *sampass, uint32_t *current_hist_len);
 const char *pdb_get_plaintext_passwd(const struct samu *sampass);
-const DOM_SID *pdb_get_user_sid(const struct samu *sampass);
-const DOM_SID *pdb_get_group_sid(struct samu *sampass);
+const struct dom_sid *pdb_get_user_sid(const struct samu *sampass);
+const struct dom_sid *pdb_get_group_sid(struct samu *sampass);
 enum pdb_value_state pdb_get_init_flags(const struct samu *sampass, enum pdb_elements element);
 const char *pdb_get_username(const struct samu *sampass);
 const char *pdb_get_domain(const struct samu *sampass);
@@ -4521,11 +4431,11 @@ const char *pdb_get_acct_desc(const struct samu *sampass);
 const char *pdb_get_workstations(const struct samu *sampass);
 const char *pdb_get_comment(const struct samu *sampass);
 const char *pdb_get_munged_dial(const struct samu *sampass);
-uint16 pdb_get_bad_password_count(const struct samu *sampass);
-uint16 pdb_get_logon_count(const struct samu *sampass);
-uint32 pdb_get_unknown_6(const struct samu *sampass);
+uint16_t pdb_get_bad_password_count(const struct samu *sampass);
+uint16_t pdb_get_logon_count(const struct samu *sampass);
+uint32_t pdb_get_unknown_6(const struct samu *sampass);
 void *pdb_get_backend_private_data(const struct samu *sampass, const struct pdb_methods *my_methods);
-bool pdb_set_acct_ctrl(struct samu *sampass, uint32 acct_ctrl, enum pdb_value_state flag);
+bool pdb_set_acct_ctrl(struct samu *sampass, uint32_t acct_ctrl, enum pdb_value_state flag);
 bool pdb_set_logon_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
 bool pdb_set_logoff_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
 bool pdb_set_kickoff_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
@@ -4533,12 +4443,12 @@ bool pdb_set_bad_password_time(struct samu *sampass, time_t mytime, enum pdb_val
 bool pdb_set_pass_can_change_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
 bool pdb_set_pass_must_change_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
 bool pdb_set_pass_last_set_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
-bool pdb_set_hours_len(struct samu *sampass, uint32 len, enum pdb_value_state flag);
-bool pdb_set_logon_divs(struct samu *sampass, uint16 hours, enum pdb_value_state flag);
+bool pdb_set_hours_len(struct samu *sampass, uint32_t len, enum pdb_value_state flag);
+bool pdb_set_logon_divs(struct samu *sampass, uint16_t hours, enum pdb_value_state flag);
 bool pdb_set_init_flags(struct samu *sampass, enum pdb_elements element, enum pdb_value_state value_flag);
-bool pdb_set_user_sid(struct samu *sampass, const DOM_SID *u_sid, enum pdb_value_state flag);
+bool pdb_set_user_sid(struct samu *sampass, const struct dom_sid *u_sid, enum pdb_value_state flag);
 bool pdb_set_user_sid_from_string(struct samu *sampass, fstring u_sid, enum pdb_value_state flag);
-bool pdb_set_group_sid(struct samu *sampass, const DOM_SID *g_sid, enum pdb_value_state flag);
+bool pdb_set_group_sid(struct samu *sampass, const struct dom_sid *g_sid, enum pdb_value_state flag);
 bool pdb_set_username(struct samu *sampass, const char *username, enum pdb_value_state flag);
 bool pdb_set_domain(struct samu *sampass, const char *domain, enum pdb_value_state flag);
 bool pdb_set_nt_username(struct samu *sampass, const char *nt_username, enum pdb_value_state flag);
@@ -4551,21 +4461,21 @@ bool pdb_set_acct_desc(struct samu *sampass, const char *acct_desc, enum pdb_val
 bool pdb_set_workstations(struct samu *sampass, const char *workstations, enum pdb_value_state flag);
 bool pdb_set_comment(struct samu *sampass, const char *comment, enum pdb_value_state flag);
 bool pdb_set_munged_dial(struct samu *sampass, const char *munged_dial, enum pdb_value_state flag);
-bool pdb_set_nt_passwd(struct samu *sampass, const uint8 pwd[NT_HASH_LEN], enum pdb_value_state flag);
-bool pdb_set_lanman_passwd(struct samu *sampass, const uint8 pwd[LM_HASH_LEN], enum pdb_value_state flag);
-bool pdb_set_pw_history(struct samu *sampass, const uint8 *pwd, uint32 historyLen, enum pdb_value_state flag);
+bool pdb_set_nt_passwd(struct samu *sampass, const uint8_t pwd[NT_HASH_LEN], enum pdb_value_state flag);
+bool pdb_set_lanman_passwd(struct samu *sampass, const uint8_t pwd[LM_HASH_LEN], enum pdb_value_state flag);
+bool pdb_set_pw_history(struct samu *sampass, const uint8_t *pwd, uint32_t historyLen, enum pdb_value_state flag);
 bool pdb_set_plaintext_pw_only(struct samu *sampass, const char *password, enum pdb_value_state flag);
-bool pdb_set_bad_password_count(struct samu *sampass, uint16 bad_password_count, enum pdb_value_state flag);
-bool pdb_set_logon_count(struct samu *sampass, uint16 logon_count, enum pdb_value_state flag);
-bool pdb_set_unknown_6(struct samu *sampass, uint32 unkn, enum pdb_value_state flag);
-bool pdb_set_hours(struct samu *sampass, const uint8 *hours, enum pdb_value_state flag);
+bool pdb_set_bad_password_count(struct samu *sampass, uint16_t bad_password_count, enum pdb_value_state flag);
+bool pdb_set_logon_count(struct samu *sampass, uint16_t logon_count, enum pdb_value_state flag);
+bool pdb_set_unknown_6(struct samu *sampass, uint32_t unkn, enum pdb_value_state flag);
+bool pdb_set_hours(struct samu *sampass, const uint8_t *hours, enum pdb_value_state flag);
 bool pdb_set_backend_private_data(struct samu *sampass, void *private_data, 
                                   void (*free_fn)(void **), 
                                   const struct pdb_methods *my_methods, 
                                   enum pdb_value_state flag);
 bool pdb_set_pass_can_change(struct samu *sampass, bool canchange);
 bool pdb_set_plaintext_passwd(struct samu *sampass, const char *plaintext);
-uint32 pdb_build_fields_present(struct samu *sampass);
+uint32_t pdb_build_fields_present(struct samu *sampass);
 
 /* The following definitions come from passdb/pdb_interface.c  */
 
@@ -4575,85 +4485,85 @@ struct event_context *pdb_get_event_context(void);
 NTSTATUS make_pdb_method_name(struct pdb_methods **methods, const char *selected);
 struct pdb_domain_info *pdb_get_domain_info(TALLOC_CTX *mem_ctx);
 bool pdb_getsampwnam(struct samu *sam_acct, const char *username) ;
-bool pdb_getsampwsid(struct samu *sam_acct, const DOM_SID *sid) ;
-NTSTATUS pdb_create_user(TALLOC_CTX *mem_ctx, const char *name, uint32 flags,
-                        uint32 *rid);
+bool pdb_getsampwsid(struct samu *sam_acct, const struct dom_sid *sid) ;
+NTSTATUS pdb_create_user(TALLOC_CTX *mem_ctx, const char *name, uint32_t flags,
+                        uint32_t *rid);
 NTSTATUS pdb_delete_user(TALLOC_CTX *mem_ctx, struct samu *sam_acct);
 NTSTATUS pdb_add_sam_account(struct samu *sam_acct) ;
 NTSTATUS pdb_update_sam_account(struct samu *sam_acct) ;
 NTSTATUS pdb_delete_sam_account(struct samu *sam_acct) ;
 NTSTATUS pdb_rename_sam_account(struct samu *oldname, const char *newname);
 NTSTATUS pdb_update_login_attempts(struct samu *sam_acct, bool success);
-bool pdb_getgrsid(GROUP_MAP *map, DOM_SID sid);
+bool pdb_getgrsid(GROUP_MAP *map, struct dom_sid sid);
 bool pdb_getgrgid(GROUP_MAP *map, gid_t gid);
 bool pdb_getgrnam(GROUP_MAP *map, const char *name);
 NTSTATUS pdb_create_dom_group(TALLOC_CTX *mem_ctx, const char *name,
-                             uint32 *rid);
-NTSTATUS pdb_delete_dom_group(TALLOC_CTX *mem_ctx, uint32 rid);
+                             uint32_t *rid);
+NTSTATUS pdb_delete_dom_group(TALLOC_CTX *mem_ctx, uint32_t rid);
 NTSTATUS pdb_add_group_mapping_entry(GROUP_MAP *map);
 NTSTATUS pdb_update_group_mapping_entry(GROUP_MAP *map);
-NTSTATUS pdb_delete_group_mapping_entry(DOM_SID sid);
-bool pdb_enum_group_mapping(const DOM_SID *sid, enum lsa_SidType sid_name_use, GROUP_MAP **pp_rmap,
+NTSTATUS pdb_delete_group_mapping_entry(struct dom_sid sid);
+bool pdb_enum_group_mapping(const struct dom_sid *sid, enum lsa_SidType sid_name_use, GROUP_MAP **pp_rmap,
                            size_t *p_num_entries, bool unix_only);
 NTSTATUS pdb_enum_group_members(TALLOC_CTX *mem_ctx,
-                               const DOM_SID *sid,
-                               uint32 **pp_member_rids,
+                               const struct dom_sid *sid,
+                               uint32_t **pp_member_rids,
                                size_t *p_num_members);
 NTSTATUS pdb_enum_group_memberships(TALLOC_CTX *mem_ctx, struct samu *user,
-                                   DOM_SID **pp_sids, gid_t **pp_gids,
+                                   struct dom_sid **pp_sids, gid_t **pp_gids,
                                    size_t *p_num_groups);
 NTSTATUS pdb_set_unix_primary_group(TALLOC_CTX *mem_ctx, struct samu *user);
-NTSTATUS pdb_add_groupmem(TALLOC_CTX *mem_ctx, uint32 group_rid,
-                         uint32 member_rid);
-NTSTATUS pdb_del_groupmem(TALLOC_CTX *mem_ctx, uint32 group_rid,
-                         uint32 member_rid);
-NTSTATUS pdb_create_alias(const char *name, uint32 *rid);
-NTSTATUS pdb_delete_alias(const DOM_SID *sid);
-NTSTATUS pdb_get_aliasinfo(const DOM_SID *sid, struct acct_info *info);
-NTSTATUS pdb_set_aliasinfo(const DOM_SID *sid, struct acct_info *info);
-NTSTATUS pdb_add_aliasmem(const DOM_SID *alias, const DOM_SID *member);
-NTSTATUS pdb_del_aliasmem(const DOM_SID *alias, const DOM_SID *member);
-NTSTATUS pdb_enum_aliasmem(const DOM_SID *alias, TALLOC_CTX *mem_ctx,
-                          DOM_SID **pp_members, size_t *p_num_members);
+NTSTATUS pdb_add_groupmem(TALLOC_CTX *mem_ctx, uint32_t group_rid,
+                         uint32_t member_rid);
+NTSTATUS pdb_del_groupmem(TALLOC_CTX *mem_ctx, uint32_t group_rid,
+                         uint32_t member_rid);
+NTSTATUS pdb_create_alias(const char *name, uint32_t *rid);
+NTSTATUS pdb_delete_alias(const struct dom_sid *sid);
+NTSTATUS pdb_get_aliasinfo(const struct dom_sid *sid, struct acct_info *info);
+NTSTATUS pdb_set_aliasinfo(const struct dom_sid *sid, struct acct_info *info);
+NTSTATUS pdb_add_aliasmem(const struct dom_sid *alias, const struct dom_sid *member);
+NTSTATUS pdb_del_aliasmem(const struct dom_sid *alias, const struct dom_sid *member);
+NTSTATUS pdb_enum_aliasmem(const struct dom_sid *alias, TALLOC_CTX *mem_ctx,
+                          struct dom_sid **pp_members, size_t *p_num_members);
 NTSTATUS pdb_enum_alias_memberships(TALLOC_CTX *mem_ctx,
-                                   const DOM_SID *domain_sid,
-                                   const DOM_SID *members, size_t num_members,
-                                   uint32 **pp_alias_rids,
+                                   const struct dom_sid *domain_sid,
+                                   const struct dom_sid *members, size_t num_members,
+                                   uint32_t **pp_alias_rids,
                                    size_t *p_num_alias_rids);
-NTSTATUS pdb_lookup_rids(const DOM_SID *domain_sid,
+NTSTATUS pdb_lookup_rids(const struct dom_sid *domain_sid,
                         int num_rids,
-                        uint32 *rids,
+                        uint32_t *rids,
                         const char **names,
                         enum lsa_SidType *attrs);
-NTSTATUS pdb_lookup_names(const DOM_SID *domain_sid,
+NTSTATUS pdb_lookup_names(const struct dom_sid *domain_sid,
                          int num_names,
                          const char **names,
-                         uint32 *rids,
+                         uint32_t *rids,
                          enum lsa_SidType *attrs);
 bool pdb_get_account_policy(enum pdb_policy_type type, uint32_t *value);
 bool pdb_set_account_policy(enum pdb_policy_type type, uint32_t value);
 bool pdb_get_seq_num(time_t *seq_num);
-bool pdb_uid_to_sid(uid_t uid, DOM_SID *sid);
-bool pdb_gid_to_sid(gid_t gid, DOM_SID *sid);
-bool pdb_sid_to_id(const DOM_SID *sid, union unid_t *id,
+bool pdb_uid_to_sid(uid_t uid, struct dom_sid *sid);
+bool pdb_gid_to_sid(gid_t gid, struct dom_sid *sid);
+bool pdb_sid_to_id(const struct dom_sid *sid, union unid_t *id,
                   enum lsa_SidType *type);
 uint32_t pdb_capabilities(void);
-bool pdb_new_rid(uint32 *rid);
+bool pdb_new_rid(uint32_t *rid);
 bool initialize_password_db(bool reload, struct event_context *event_ctx);
 struct pdb_search *pdb_search_init(TALLOC_CTX *mem_ctx,
                                   enum pdb_search_type type);
-struct pdb_search *pdb_search_users(TALLOC_CTX *mem_ctx, uint32 acct_flags);
+struct pdb_search *pdb_search_users(TALLOC_CTX *mem_ctx, uint32_t acct_flags);
 struct pdb_search *pdb_search_groups(TALLOC_CTX *mem_ctx);
-struct pdb_search *pdb_search_aliases(TALLOC_CTX *mem_ctx, const DOM_SID *sid);
-uint32 pdb_search_entries(struct pdb_search *search,
-                         uint32 start_idx, uint32 max_entries,
+struct pdb_search *pdb_search_aliases(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
+uint32_t pdb_search_entries(struct pdb_search *search,
+                         uint32_t start_idx, uint32_t max_entries,
                          struct samr_displayentry **result);
-bool pdb_get_trusteddom_pw(const char *domain, char** pwd, DOM_SID *sid, 
+bool pdb_get_trusteddom_pw(const char *domain, char** pwd, struct dom_sid *sid,
                           time_t *pass_last_set_time);
 bool pdb_set_trusteddom_pw(const char* domain, const char* pwd,
-                          const DOM_SID *sid);
+                          const struct dom_sid *sid);
 bool pdb_del_trusteddom_pw(const char *domain);
-NTSTATUS pdb_enum_trusteddoms(TALLOC_CTX *mem_ctx, uint32 *num_domains,
+NTSTATUS pdb_enum_trusteddoms(TALLOC_CTX *mem_ctx, uint32_t *num_domains,
                              struct trustdom_info ***domains);
 NTSTATUS make_pdb_method( struct pdb_methods **methods ) ;
 
@@ -4692,7 +4602,7 @@ NTSTATUS pdb_wbc_sam_init(void);
 
 /* The following definitions come from passdb/pdb_tdb.c  */
 
-bool init_sam_from_buffer_v2(struct samu *sampass, uint8 *buf, uint32 buflen);
+bool init_sam_from_buffer_v2(struct samu *sampass, uint8_t *buf, uint32_t buflen);
 NTSTATUS pdb_tdbsam_init(void);
 
 /* The following definitions come from passdb/secrets.c  */
@@ -4703,8 +4613,8 @@ void secrets_shutdown(void);
 void *secrets_fetch(const char *key, size_t *size);
 bool secrets_store(const char *key, const void *data, size_t size);
 bool secrets_delete(const char *key);
-bool secrets_store_domain_sid(const char *domain, const DOM_SID *sid);
-bool secrets_fetch_domain_sid(const char *domain, DOM_SID *sid);
+bool secrets_store_domain_sid(const char *domain, const struct dom_sid  *sid);
+bool secrets_fetch_domain_sid(const char *domain, struct dom_sid  *sid);
 bool secrets_store_domain_guid(const char *domain, struct GUID *guid);
 bool secrets_fetch_domain_guid(const char *domain, struct GUID *guid);
 void *secrets_get_trust_account_lock(TALLOC_CTX *mem_ctx, const char *domain);
@@ -4717,9 +4627,9 @@ bool secrets_fetch_trust_account_password(const char *domain, uint8 ret_pwd[16],
                                          time_t *pass_last_set_time,
                                          enum netr_SchannelType *channel);
 bool secrets_fetch_trusted_domain_password(const char *domain, char** pwd,
-                                           DOM_SID *sid, time_t *pass_last_set_time);
+                                           struct dom_sid  *sid, time_t *pass_last_set_time);
 bool secrets_store_trusted_domain_password(const char* domain, const char* pwd,
-                                           const DOM_SID *sid);
+                                           const struct dom_sid  *sid);
 bool secrets_delete_machine_password(const char *domain);
 bool secrets_delete_machine_password_ex(const char *domain);
 bool secrets_delete_domain_sid(const char *domain);
@@ -4746,30 +4656,30 @@ bool secrets_fetch_local_schannel_key(uint8_t schannel_key[16]);
 bool lookup_builtin_rid(TALLOC_CTX *mem_ctx, uint32 rid, const char **name);
 bool lookup_builtin_name(const char *name, uint32 *rid);
 const char *builtin_domain_name(void);
-bool sid_check_is_builtin(const DOM_SID *sid);
-bool sid_check_is_in_builtin(const DOM_SID *sid);
+bool sid_check_is_builtin(const struct dom_sid *sid);
+bool sid_check_is_in_builtin(const struct dom_sid *sid);
 
 /* The following definitions come from passdb/util_unixsids.c  */
 
-bool sid_check_is_unix_users(const DOM_SID *sid);
-bool sid_check_is_in_unix_users(const DOM_SID *sid);
-bool uid_to_unix_users_sid(uid_t uid, DOM_SID *sid);
-bool gid_to_unix_groups_sid(gid_t gid, DOM_SID *sid);
+bool sid_check_is_unix_users(const struct dom_sid *sid);
+bool sid_check_is_in_unix_users(const struct dom_sid *sid);
+bool uid_to_unix_users_sid(uid_t uid, struct dom_sid *sid);
+bool gid_to_unix_groups_sid(gid_t gid, struct dom_sid *sid);
 const char *unix_users_domain_name(void);
-bool lookup_unix_user_name(const char *name, DOM_SID *sid);
-bool sid_check_is_unix_groups(const DOM_SID *sid);
-bool sid_check_is_in_unix_groups(const DOM_SID *sid);
+bool lookup_unix_user_name(const char *name, struct dom_sid *sid);
+bool sid_check_is_unix_groups(const struct dom_sid *sid);
+bool sid_check_is_in_unix_groups(const struct dom_sid *sid);
 const char *unix_groups_domain_name(void);
-bool lookup_unix_group_name(const char *name, DOM_SID *sid);
+bool lookup_unix_group_name(const char *name, struct dom_sid *sid);
 
 /* The following definitions come from passdb/util_wellknown.c  */
 
-bool sid_check_is_wellknown_domain(const DOM_SID *sid, const char **name);
-bool sid_check_is_in_wellknown_domain(const DOM_SID *sid);
-bool lookup_wellknown_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
+bool sid_check_is_wellknown_domain(const struct dom_sid *sid, const char **name);
+bool sid_check_is_in_wellknown_domain(const struct dom_sid *sid);
+bool lookup_wellknown_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
                          const char **domain, const char **name);
 bool lookup_wellknown_name(TALLOC_CTX *mem_ctx, const char *name,
-                          DOM_SID *sid, const char **domain);
+                          struct dom_sid *sid, const char **domain);
 
 /* The following definitions come from printing/load.c  */
 
@@ -4837,6 +4747,7 @@ WERROR spoolss_create_default_devmode(TALLOC_CTX *mem_ctx,
                                      struct spoolss_DeviceMode **devmode);
 WERROR spoolss_create_default_secdesc(TALLOC_CTX *mem_ctx,
                                      struct spoolss_security_descriptor **secdesc);
+WERROR spoolss_map_to_os2_driver(TALLOC_CTX *mem_ctx, const char **pdrivername);
 int add_new_printer_key( NT_PRINTER_DATA *data, const char *name );
 int delete_printer_key( NT_PRINTER_DATA *data, const char *name );
 int lookup_printerkey( NT_PRINTER_DATA *data, const char *name );
@@ -4855,9 +4766,6 @@ WERROR add_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const cha
                            uint32 type, uint8 *data, int real_len );
 struct regval_blob* get_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value );
 WERROR mod_a_printer(NT_PRINTER_INFO_LEVEL *printer, uint32 level);
-bool set_driver_init(NT_PRINTER_INFO_LEVEL *printer, uint32 level);
-bool del_driver_init(const char *drivername);
-WERROR save_driver_init(NT_PRINTER_INFO_LEVEL *printer, uint32 level, uint8 *data, uint32 data_len);
 WERROR get_a_printer( Printer_entry *print_hnd,
                        NT_PRINTER_INFO_LEVEL **pp_printer,
                        uint32 level,
@@ -4884,10 +4792,10 @@ bool printer_driver_files_in_use(TALLOC_CTX *mem_ctx,
 WERROR delete_printer_driver(struct pipes_struct *rpc_pipe,
                             const struct spoolss_DriverInfo8 *r,
                             uint32 version, bool delete_files );
-WERROR nt_printing_setsec(const char *sharename, SEC_DESC_BUF *secdesc_ctr);
-bool nt_printing_getsec(TALLOC_CTX *ctx, const char *sharename, SEC_DESC_BUF **secdesc_ctr);
-void map_printer_permissions(SEC_DESC *sd);
-void map_job_permissions(SEC_DESC *sd);
+WERROR nt_printing_setsec(const char *sharename, struct sec_desc_buf *secdesc_ctr);
+bool nt_printing_getsec(TALLOC_CTX *ctx, const char *sharename, struct sec_desc_buf **secdesc_ctr);
+void map_printer_permissions(struct security_descriptor *sd);
+void map_job_permissions(struct security_descriptor *sd);
 bool print_access_check(struct auth_serversupplied_info *server_info, int snum,
                        int access_type);
 bool print_time_access_check(const char *servicename);
@@ -4895,42 +4803,8 @@ char* get_server_name( Printer_entry *printer );
 
 /* The following definitions come from printing/pcap.c  */
 
-bool pcap_cache_add_specific(struct pcap_cache **ppcache, const char *name, const char *comment);
-void pcap_cache_destroy_specific(struct pcap_cache **ppcache);
-bool pcap_cache_add(const char *name, const char *comment);
-bool pcap_cache_loaded(void);
-void pcap_cache_replace(const struct pcap_cache *cache);
 void pcap_cache_reload(void);
 bool pcap_printername_ok(const char *printername);
-void pcap_printer_fn_specific(const struct pcap_cache *, void (*fn)(const char *, const char *, void *), void *);
-void pcap_printer_fn(void (*fn)(const char *, const char *, void *), void *);
-
-/* The following definitions come from printing/print_aix.c  */
-
-bool aix_cache_reload(void);
-
-/* The following definitions come from printing/print_cups.c  */
-
-bool cups_cache_reload(void);
-bool cups_pull_comment_location(TALLOC_CTX *mem_ctx,
-                               const char *printername,
-                               char **comment,
-                               char **location);
-
-/* The following definitions come from printing/print_generic.c  */
-
-
-/* The following definitions come from printing/print_iprint.c  */
-
-bool iprint_cache_reload(void);
-
-/* The following definitions come from printing/print_svid.c  */
-
-bool sysv_cache_reload(void);
-
-/* The following definitions come from printing/print_standard.c  */
-
-bool std_pcap_cache_reload(const char *pcap_name);
 
 /* The following definitions come from printing/printfsp.c  */
 
@@ -4989,310 +4863,6 @@ TDB_DATA get_printer_notify_pid_list(TDB_CONTEXT *tdb, const char *printer_name,
 void set_profile_level(int level, struct server_id src);
 bool profile_setup(struct messaging_context *msg_ctx, bool rdonly);
 
-/* The following definitions come from registry/reg_api.c  */
-
-WERROR reg_openhive(TALLOC_CTX *mem_ctx, const char *hive,
-                   uint32 desired_access,
-                   const struct nt_user_token *token,
-                   struct registry_key **pkey);
-WERROR reg_openkey(TALLOC_CTX *mem_ctx, struct registry_key *parent,
-                  const char *name, uint32 desired_access,
-                  struct registry_key **pkey);
-WERROR reg_enumkey(TALLOC_CTX *mem_ctx, struct registry_key *key,
-                  uint32 idx, char **name, NTTIME *last_write_time);
-WERROR reg_enumvalue(TALLOC_CTX *mem_ctx, struct registry_key *key,
-                    uint32 idx, char **pname, struct registry_value **pval);
-WERROR reg_queryvalue(TALLOC_CTX *mem_ctx, struct registry_key *key,
-                     const char *name, struct registry_value **pval);
-WERROR reg_queryinfokey(struct registry_key *key, uint32_t *num_subkeys,
-                       uint32_t *max_subkeylen, uint32_t *max_subkeysize, 
-                       uint32_t *num_values, uint32_t *max_valnamelen, 
-                       uint32_t *max_valbufsize, uint32_t *secdescsize,
-                       NTTIME *last_changed_time);
-WERROR reg_createkey(TALLOC_CTX *ctx, struct registry_key *parent,
-                    const char *subkeypath, uint32 desired_access,
-                    struct registry_key **pkey,
-                    enum winreg_CreateAction *paction);
-WERROR reg_deletekey(struct registry_key *parent, const char *path);
-WERROR reg_setvalue(struct registry_key *key, const char *name,
-                   const struct registry_value *val);
-WERROR reg_deletevalue(struct registry_key *key, const char *name);
-WERROR reg_getkeysecurity(TALLOC_CTX *mem_ctx, struct registry_key *key,
-                         struct security_descriptor **psecdesc);
-WERROR reg_setkeysecurity(struct registry_key *key,
-                         struct security_descriptor *psecdesc);
-WERROR reg_getversion(uint32_t *version);
-WERROR reg_restorekey(struct registry_key *key, const char *fname);
-WERROR reg_savekey(struct registry_key *key, const char *fname);
-WERROR reg_deleteallvalues(struct registry_key *key);
-WERROR reg_open_path(TALLOC_CTX *mem_ctx, const char *orig_path,
-                    uint32 desired_access, const struct nt_user_token *token,
-                    struct registry_key **pkey);
-WERROR reg_deletekey_recursive(TALLOC_CTX *ctx,
-                              struct registry_key *parent,
-                              const char *path);
-WERROR reg_deletesubkeys_recursive(TALLOC_CTX *ctx,
-                                  struct registry_key *parent,
-                                  const char *path);
-WERROR reg_create_path(TALLOC_CTX *mem_ctx, const char *orig_path,
-                      uint32 desired_access,
-                      const struct nt_user_token *token,
-                      enum winreg_CreateAction *paction,
-                      struct registry_key **pkey);
-WERROR reg_delete_path(const struct nt_user_token *token,
-                      const char *orig_path);
-
-/* The following definitions come from registry/reg_backend_current_version.c  */
-
-
-/* The following definitions come from registry/reg_backend_db.c  */
-
-WERROR init_registry_key(const char *add_path);
-WERROR init_registry_data(void);
-WERROR regdb_init(void);
-WERROR regdb_open( void );
-int regdb_close( void );
-WERROR regdb_transaction_start(void);
-WERROR regdb_transaction_commit(void);
-WERROR regdb_transaction_cancel(void);
-int regdb_get_seqnum(void);
-bool regdb_store_keys(const char *key, struct regsubkey_ctr *ctr);
-int regdb_fetch_keys(const char *key, struct regsubkey_ctr *ctr);
-int regdb_fetch_values(const char* key, struct regval_ctr *values);
-bool regdb_store_values(const char *key, struct regval_ctr *values);
-bool regdb_subkeys_need_update(struct regsubkey_ctr *subkeys);
-bool regdb_values_need_update(struct regval_ctr *values);
-
-/* The following definitions come from registry/reg_backend_hkpt_params.c  */
-
-
-/* The following definitions come from registry/reg_backend_netlogon_params.c  */
-
-
-/* The following definitions come from registry/reg_backend_perflib.c  */
-
-
-/* The following definitions come from registry/reg_backend_printing.c  */
-
-
-/* The following definitions come from registry/reg_backend_prod_options.c  */
-
-
-/* The following definitions come from registry/reg_backend_shares.c  */
-
-
-/* The following definitions come from registry/reg_backend_smbconf.c  */
-
-
-/* The following definitions come from registry/reg_backend_tcpip_params.c  */
-
-
-/* The following definitions come from registry/reg_cachehook.c  */
-
-WERROR reghook_cache_init(void);
-WERROR reghook_cache_add(const char *keyname, struct registry_ops *ops);
-struct registry_ops *reghook_cache_find(const char *keyname);
-void reghook_dump_cache( int debuglevel );
-
-/* The following definitions come from registry/reg_dispatcher.c  */
-
-bool store_reg_keys(struct registry_key_handle *key,
-                   struct regsubkey_ctr *subkeys);
-bool store_reg_values(struct registry_key_handle *key, struct regval_ctr *val);
-WERROR create_reg_subkey(struct registry_key_handle *key, const char *subkey);
-WERROR delete_reg_subkey(struct registry_key_handle *key, const char *subkey);
-int fetch_reg_keys(struct registry_key_handle *key,
-                  struct regsubkey_ctr *subkey_ctr);
-int fetch_reg_values(struct registry_key_handle *key, struct regval_ctr *val);
-bool regkey_access_check(struct registry_key_handle *key, uint32 requested,
-                        uint32 *granted,
-                        const struct nt_user_token *token);
-WERROR regkey_get_secdesc(TALLOC_CTX *mem_ctx, struct registry_key_handle *key,
-                         struct security_descriptor **psecdesc);
-WERROR regkey_set_secdesc(struct registry_key_handle *key,
-                         struct security_descriptor *psecdesc);
-bool reg_subkeys_need_update(struct registry_key_handle *key,
-                            struct regsubkey_ctr *subkeys);
-bool reg_values_need_update(struct registry_key_handle *key,
-                           struct regval_ctr *values);
-
-/* The following definitions come from registry/reg_eventlog.c  */
-
-bool eventlog_init_keys(void);
-bool eventlog_add_source( const char *eventlog, const char *sourcename,
-                         const char *messagefile );
-
-/* The following definitions come from registry/reg_init_basic.c  */
-
-WERROR registry_init_common(void);
-WERROR registry_init_basic(void);
-
-/* The following definitions come from registry/reg_init_full.c  */
-
-WERROR registry_init_full(void);
-
-/* The following definitions come from registry/reg_init_smbconf.c  */
-
-NTSTATUS registry_create_admin_token(TALLOC_CTX *mem_ctx,
-                                    NT_USER_TOKEN **ptoken);
-WERROR registry_init_smbconf(const char *keyname);
-
-/* The following definitions come from registry/reg_objects.c  */
-
-WERROR regsubkey_ctr_init(TALLOC_CTX *mem_ctx, struct regsubkey_ctr **ctr);
-WERROR regsubkey_ctr_reinit(struct regsubkey_ctr *ctr);
-WERROR regsubkey_ctr_set_seqnum(struct regsubkey_ctr *ctr, int seqnum);
-int regsubkey_ctr_get_seqnum(struct regsubkey_ctr *ctr);
-WERROR regsubkey_ctr_addkey( struct regsubkey_ctr *ctr, const char *keyname );
-WERROR regsubkey_ctr_delkey( struct regsubkey_ctr *ctr, const char *keyname );
-bool regsubkey_ctr_key_exists( struct regsubkey_ctr *ctr, const char *keyname );
-int regsubkey_ctr_numkeys( struct regsubkey_ctr *ctr );
-char* regsubkey_ctr_specific_key( struct regsubkey_ctr *ctr, uint32 key_index );
-int regval_ctr_numvals(struct regval_ctr *ctr);
-struct regval_blob* dup_registry_value(struct regval_blob *val);
-void free_registry_value(struct regval_blob *val);
-uint8* regval_data_p(struct regval_blob *val);
-uint32 regval_size(struct regval_blob *val);
-char* regval_name(struct regval_blob *val);
-uint32 regval_type(struct regval_blob *val);
-struct regval_blob* regval_ctr_specific_value(struct regval_ctr *ctr,
-                                             uint32 idx);
-bool regval_ctr_key_exists(struct regval_ctr *ctr, const char *value);
-struct regval_blob *regval_compose(TALLOC_CTX *ctx, const char *name,
-                                  uint16 type,
-                                  const char *data_p, size_t size);
-int regval_ctr_addvalue(struct regval_ctr *ctr, const char *name, uint16 type,
-                       const char *data_p, size_t size);
-int regval_ctr_addvalue_sz(struct regval_ctr *ctr, const char *name, const char *data);
-int regval_ctr_addvalue_multi_sz(struct regval_ctr *ctr, const char *name, const char **data);
-int regval_ctr_copyvalue(struct regval_ctr *ctr, struct regval_blob *val);
-int regval_ctr_delvalue(struct regval_ctr *ctr, const char *name);
-struct regval_blob* regval_ctr_getvalue(struct regval_ctr *ctr,
-                                       const char *name);
-uint32 regval_dword(struct regval_blob *val);
-const char *regval_sz(struct regval_blob *val);
-
-/* The following definitions come from registry/reg_perfcount.c  */
-
-void perfcount_init_keys( void );
-uint32 reg_perfcount_get_base_index(void);
-uint32 reg_perfcount_get_last_counter(uint32 base_index);
-uint32 reg_perfcount_get_last_help(uint32 last_counter);
-uint32 reg_perfcount_get_counter_help(uint32 base_index, char **retbuf);
-uint32 reg_perfcount_get_counter_names(uint32 base_index, char **retbuf);
-WERROR reg_perfcount_get_hkpd(prs_struct *ps, uint32 max_buf_size, uint32 *outbuf_len, const char *object_ids);
-
-/* The following definitions come from registry/reg_util.c  */
-
-bool reg_split_path(char *path, char **base, char **new_path);
-bool reg_split_key(char *path, char **base, char **key);
-char *normalize_reg_path(TALLOC_CTX *ctx, const char *keyname );
-void normalize_dbkey(char *key);
-char *reg_remaining_path(TALLOC_CTX *ctx, const char *key);
-
-/* The following definitions come from registry/reg_util_legacy.c  */
-
-WERROR regkey_open_internal(TALLOC_CTX *ctx,
-                           struct registry_key_handle **regkey,
-                           const char *path,
-                           const struct nt_user_token *token,
-                           uint32 access_desired );
-
-/* The following definitions come from registry/regfio.c  */
-
-
-/* The following definitions come from rpc_client/cli_lsarpc.c  */
-
-NTSTATUS rpccli_lsa_open_policy(struct rpc_pipe_client *cli,
-                               TALLOC_CTX *mem_ctx,
-                               bool sec_qos, uint32 des_access,
-                               struct policy_handle *pol);
-NTSTATUS rpccli_lsa_open_policy2(struct rpc_pipe_client *cli,
-                                TALLOC_CTX *mem_ctx, bool sec_qos,
-                                uint32 des_access, struct policy_handle *pol);
-NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
-                               TALLOC_CTX *mem_ctx,
-                               struct policy_handle *pol,
-                               int num_sids,
-                               const DOM_SID *sids,
-                               char ***pdomains,
-                               char ***pnames,
-                               enum lsa_SidType **ptypes);
-NTSTATUS rpccli_lsa_lookup_sids3(struct rpc_pipe_client *cli,
-                                TALLOC_CTX *mem_ctx,
-                                struct policy_handle *pol,
-                                int num_sids,
-                                const DOM_SID *sids,
-                                char ***pdomains,
-                                char ***pnames,
-                                enum lsa_SidType **ptypes);
-NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,
-                                TALLOC_CTX *mem_ctx,
-                                struct policy_handle *pol, int num_names,
-                                const char **names,
-                                const char ***dom_names,
-                                int level,
-                                DOM_SID **sids,
-                                enum lsa_SidType **types);
-NTSTATUS rpccli_lsa_lookup_names4(struct rpc_pipe_client *cli,
-                                 TALLOC_CTX *mem_ctx,
-                                 struct policy_handle *pol, int num_names,
-                                 const char **names,
-                                 const char ***dom_names,
-                                 int level,
-                                 DOM_SID **sids,
-                                 enum lsa_SidType **types);
-
-bool fetch_domain_sid( char *domain, char *remote_machine, DOM_SID *psid);
-
-/* The following definitions come from rpc_client/cli_netlogon.c  */
-
-NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli,
-                                    const char *server_name,
-                                    const char *domain,
-                                    const char *clnt_name,
-                                    const char *machine_account,
-                                    const unsigned char machine_pwd[16],
-                                    enum netr_SchannelType sec_chan_type,
-                                    uint32_t *neg_flags_inout);
-NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli,
-                                  TALLOC_CTX *mem_ctx,
-                                  uint32 logon_parameters,
-                                  const char *domain,
-                                  const char *username,
-                                  const char *password,
-                                  const char *workstation,
-                                  int logon_type);
-NTSTATUS rpccli_netlogon_sam_network_logon(struct rpc_pipe_client *cli,
-                                          TALLOC_CTX *mem_ctx,
-                                          uint32 logon_parameters,
-                                          const char *server,
-                                          const char *username,
-                                          const char *domain,
-                                          const char *workstation,
-                                          const uint8 chal[8],
-                                          DATA_BLOB lm_response,
-                                          DATA_BLOB nt_response,
-                                          struct netr_SamInfo3 **info3);
-NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli,
-                                             TALLOC_CTX *mem_ctx,
-                                             uint32 logon_parameters,
-                                             const char *server,
-                                             const char *username,
-                                             const char *domain,
-                                             const char *workstation,
-                                             const uint8 chal[8],
-                                             DATA_BLOB lm_response,
-                                             DATA_BLOB nt_response,
-                                             struct netr_SamInfo3 **info3);
-NTSTATUS rpccli_netlogon_set_trust_password(struct rpc_pipe_client *cli,
-                                           TALLOC_CTX *mem_ctx,
-                                           const char *account_name,
-                                           const unsigned char orig_trust_passwd_hash[16],
-                                           const char *new_trust_pwd_cleartext,
-                                           const unsigned char new_trust_passwd_hash[16],
-                                           enum netr_SchannelType sec_channel_type);
-
 /* The following definitions come from rpc_client/cli_pipe.c  */
 
 struct tevent_req *rpc_api_pipe_req_send(TALLOC_CTX *mem_ctx,
@@ -5329,6 +4899,8 @@ NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id
                                NTSTATUS (*dispatch) (struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *r),
                                struct auth_serversupplied_info *serversupplied_info,
                                struct rpc_pipe_client **presult);
+NTSTATUS rpc_connect_spoolss_pipe(connection_struct *conn,
+                                 struct rpc_pipe_client **spoolss_pipe);
 NTSTATUS cli_rpc_pipe_open_noauth(struct cli_state *cli,
                                  const struct ndr_syntax_id *interface,
                                  struct rpc_pipe_client **presult);
@@ -5442,177 +5014,6 @@ struct cli_state *rpc_pipe_smbd_smb_conn(struct rpc_pipe_client *p);
 NTSTATUS rpc_transport_sock_init(TALLOC_CTX *mem_ctx, int fd,
                                 struct rpc_cli_transport **presult);
 
-/* The following definitions come from rpc_client/cli_samr.c  */
-
-NTSTATUS rpccli_samr_chgpasswd_user(struct rpc_pipe_client *cli,
-                                   TALLOC_CTX *mem_ctx,
-                                   struct policy_handle *user_handle,
-                                   const char *newpassword,
-                                   const char *oldpassword);
-NTSTATUS rpccli_samr_chgpasswd_user2(struct rpc_pipe_client *cli,
-                                    TALLOC_CTX *mem_ctx,
-                                    const char *username,
-                                    const char *newpassword,
-                                    const char *oldpassword);
-NTSTATUS rpccli_samr_chng_pswd_auth_crap(struct rpc_pipe_client *cli,
-                                        TALLOC_CTX *mem_ctx,
-                                        const char *username,
-                                        DATA_BLOB new_nt_password_blob,
-                                        DATA_BLOB old_nt_hash_enc_blob,
-                                        DATA_BLOB new_lm_password_blob,
-                                        DATA_BLOB old_lm_hash_enc_blob);
-NTSTATUS rpccli_samr_chgpasswd_user3(struct rpc_pipe_client *cli,
-                                    TALLOC_CTX *mem_ctx,
-                                    const char *username,
-                                    const char *newpassword,
-                                    const char *oldpassword,
-                                    struct samr_DomInfo1 **dominfo1,
-                                    struct userPwdChangeFailureInformation **reject);
-void get_query_dispinfo_params(int loop_count, uint32 *max_entries,
-                              uint32 *max_size);
-NTSTATUS rpccli_try_samr_connects(struct rpc_pipe_client *cli,
-                                 TALLOC_CTX *mem_ctx,
-                                 uint32_t access_mask,
-                                 struct policy_handle *connect_pol);
-
-/* The following definitions come from rpc_client/cli_spoolss.c  */
-
-WERROR rpccli_spoolss_openprinter_ex(struct rpc_pipe_client *cli,
-                                    TALLOC_CTX *mem_ctx,
-                                    const char *printername,
-                                    uint32_t access_desired,
-                                    struct policy_handle *handle);
-WERROR rpccli_spoolss_getprinterdriver(struct rpc_pipe_client *cli,
-                                      TALLOC_CTX *mem_ctx,
-                                      struct policy_handle *handle,
-                                      const char *architecture,
-                                      uint32_t level,
-                                      uint32_t offered,
-                                      union spoolss_DriverInfo *info);
-WERROR rpccli_spoolss_getprinterdriver2(struct rpc_pipe_client *cli,
-                                       TALLOC_CTX *mem_ctx,
-                                       struct policy_handle *handle,
-                                       const char *architecture,
-                                       uint32_t level,
-                                       uint32_t offered,
-                                       uint32_t client_major_version,
-                                       uint32_t client_minor_version,
-                                       union spoolss_DriverInfo *info,
-                                       uint32_t *server_major_version,
-                                       uint32_t *server_minor_version);
-WERROR rpccli_spoolss_addprinterex(struct rpc_pipe_client *cli,
-                                  TALLOC_CTX *mem_ctx,
-                                  struct spoolss_SetPrinterInfoCtr *info_ctr);
-WERROR rpccli_spoolss_getprinter(struct rpc_pipe_client *cli,
-                                TALLOC_CTX *mem_ctx,
-                                struct policy_handle *handle,
-                                uint32_t level,
-                                uint32_t offered,
-                                union spoolss_PrinterInfo *info);
-WERROR rpccli_spoolss_getjob(struct rpc_pipe_client *cli,
-                            TALLOC_CTX *mem_ctx,
-                            struct policy_handle *handle,
-                            uint32_t job_id,
-                            uint32_t level,
-                            uint32_t offered,
-                            union spoolss_JobInfo *info);
-WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli,
-                               TALLOC_CTX *mem_ctx,
-                               struct policy_handle *handle,
-                               uint32_t level,
-                               uint32_t offered,
-                               uint32_t *count,
-                               union spoolss_FormInfo **info);
-WERROR rpccli_spoolss_enumprintprocessors(struct rpc_pipe_client *cli,
-                                         TALLOC_CTX *mem_ctx,
-                                         const char *servername,
-                                         const char *environment,
-                                         uint32_t level,
-                                         uint32_t offered,
-                                         uint32_t *count,
-                                         union spoolss_PrintProcessorInfo **info);
-WERROR rpccli_spoolss_enumprintprocessordatatypes(struct rpc_pipe_client *cli,
-                                                 TALLOC_CTX *mem_ctx,
-                                                 const char *servername,
-                                                 const char *print_processor_name,
-                                                 uint32_t level,
-                                                 uint32_t offered,
-                                                 uint32_t *count,
-                                                 union spoolss_PrintProcDataTypesInfo **info);
-WERROR rpccli_spoolss_enumports(struct rpc_pipe_client *cli,
-                               TALLOC_CTX *mem_ctx,
-                               const char *servername,
-                               uint32_t level,
-                               uint32_t offered,
-                               uint32_t *count,
-                               union spoolss_PortInfo **info);
-WERROR rpccli_spoolss_enummonitors(struct rpc_pipe_client *cli,
-                                  TALLOC_CTX *mem_ctx,
-                                  const char *servername,
-                                  uint32_t level,
-                                  uint32_t offered,
-                                  uint32_t *count,
-                                  union spoolss_MonitorInfo **info);
-WERROR rpccli_spoolss_enumjobs(struct rpc_pipe_client *cli,
-                              TALLOC_CTX *mem_ctx,
-                              struct policy_handle *handle,
-                              uint32_t firstjob,
-                              uint32_t numjobs,
-                              uint32_t level,
-                              uint32_t offered,
-                              uint32_t *count,
-                              union spoolss_JobInfo **info);
-WERROR rpccli_spoolss_enumprinterdrivers(struct rpc_pipe_client *cli,
-                                        TALLOC_CTX *mem_ctx,
-                                        const char *server,
-                                        const char *environment,
-                                        uint32_t level,
-                                        uint32_t offered,
-                                        uint32_t *count,
-                                        union spoolss_DriverInfo **info);
-WERROR rpccli_spoolss_enumprinters(struct rpc_pipe_client *cli,
-                                  TALLOC_CTX *mem_ctx,
-                                  uint32_t flags,
-                                  const char *server,
-                                  uint32_t level,
-                                  uint32_t offered,
-                                  uint32_t *count,
-                                  union spoolss_PrinterInfo **info);
-WERROR rpccli_spoolss_getprinterdata(struct rpc_pipe_client *cli,
-                                    TALLOC_CTX *mem_ctx,
-                                    struct policy_handle *handle,
-                                    const char *value_name,
-                                    uint32_t offered,
-                                    enum winreg_Type *type,
-                                    uint32_t *needed_p,
-                                    uint8_t **data_p);
-WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli,
-                                    TALLOC_CTX *mem_ctx,
-                                    struct policy_handle *handle,
-                                    const char *key_name,
-                                    const char ***key_buffer,
-                                    uint32_t offered);
-WERROR rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client *cli,
-                                       TALLOC_CTX *mem_ctx,
-                                       struct policy_handle *handle,
-                                       const char *key_name,
-                                       uint32_t offered,
-                                       uint32_t *count,
-                                       struct spoolss_PrinterEnumValues **info);
-
-/* The following definitions come from rpc_client/init_spoolss.c  */
-
-bool init_systemtime(struct spoolss_Time *r,
-                    struct tm *unixtime);
-time_t spoolss_Time_to_time_t(const struct spoolss_Time *r);
-WERROR pull_spoolss_PrinterData(TALLOC_CTX *mem_ctx,
-                               const DATA_BLOB *blob,
-                               union spoolss_PrinterData *data,
-                               enum winreg_Type type);
-WERROR push_spoolss_PrinterData(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
-                               enum winreg_Type type,
-                               union spoolss_PrinterData *data);
-
 /* The following definitions come from rpc_client/init_lsa.c  */
 
 void init_lsa_String(struct lsa_String *name, const char *s);
@@ -5620,33 +5021,6 @@ void init_lsa_StringLarge(struct lsa_StringLarge *name, const char *s);
 void init_lsa_AsciiString(struct lsa_AsciiString *name, const char *s);
 void init_lsa_AsciiStringLarge(struct lsa_AsciiStringLarge *name, const char *s);
 
-/* The following definitions come from rpc_client/init_netlogon.c  */
-
-NTSTATUS serverinfo_to_SamInfo2(struct auth_serversupplied_info *server_info,
-                               uint8_t *pipe_session_key,
-                               size_t pipe_session_key_len,
-                               struct netr_SamInfo2 *sam2);
-NTSTATUS serverinfo_to_SamInfo3(struct auth_serversupplied_info *server_info,
-                               uint8_t *pipe_session_key,
-                               size_t pipe_session_key_len,
-                               struct netr_SamInfo3 *sam3);
-NTSTATUS serverinfo_to_SamInfo6(struct auth_serversupplied_info *server_info,
-                               uint8_t *pipe_session_key,
-                               size_t pipe_session_key_len,
-                               struct netr_SamInfo6 *sam6);
-void init_netr_CryptPassword(const char *pwd,
-                            unsigned char session_key[16],
-                            struct netr_CryptPassword *pwd_buf);
-
-/* The following definitions come from rpc_client/init_samr.c  */
-
-void init_samr_CryptPasswordEx(const char *pwd,
-                              DATA_BLOB *session_key,
-                              struct samr_CryptPasswordEx *pwd_buf);
-void init_samr_CryptPassword(const char *pwd,
-                            DATA_BLOB *session_key,
-                            struct samr_CryptPassword *pwd_buf);
-
 /* The following definitions come from rpc_client/ndr.c  */
 
 struct tevent_req *cli_do_rpc_ndr_send(TALLOC_CTX *mem_ctx,
@@ -5813,10 +5187,13 @@ pipes_struct *get_first_internal_pipe(void);
 pipes_struct *get_next_internal_pipe(pipes_struct *p);
 
 bool fsp_is_np(struct files_struct *fsp);
+struct tsocket_address;
 NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
-                const char *client_address,
+                const struct tsocket_address *local_address,
+                const struct tsocket_address *remote_address,
                 struct auth_serversupplied_info *server_info,
                 struct fake_file_handle **phandle);
+bool np_read_in_progress(struct fake_file_handle *handle);
 struct tevent_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
                                 struct fake_file_handle *handle,
                                 const uint8_t *data, size_t len);
@@ -5827,46 +5204,6 @@ struct tevent_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
 NTSTATUS np_read_recv(struct tevent_req *req, ssize_t *nread,
                      bool *is_data_outstanding);
 
-/* The following definitions come from rpc_server/srv_samr_util.c  */
-
-void copy_id2_to_sam_passwd(struct samu *to,
-                           struct samr_UserInfo2 *from);
-void copy_id4_to_sam_passwd(struct samu *to,
-                           struct samr_UserInfo4 *from);
-void copy_id6_to_sam_passwd(struct samu *to,
-                           struct samr_UserInfo6 *from);
-void copy_id8_to_sam_passwd(struct samu *to,
-                           struct samr_UserInfo8 *from);
-void copy_id10_to_sam_passwd(struct samu *to,
-                            struct samr_UserInfo10 *from);
-void copy_id11_to_sam_passwd(struct samu *to,
-                            struct samr_UserInfo11 *from);
-void copy_id12_to_sam_passwd(struct samu *to,
-                            struct samr_UserInfo12 *from);
-void copy_id13_to_sam_passwd(struct samu *to,
-                            struct samr_UserInfo13 *from);
-void copy_id14_to_sam_passwd(struct samu *to,
-                            struct samr_UserInfo14 *from);
-void copy_id16_to_sam_passwd(struct samu *to,
-                            struct samr_UserInfo16 *from);
-void copy_id17_to_sam_passwd(struct samu *to,
-                            struct samr_UserInfo17 *from);
-void copy_id18_to_sam_passwd(struct samu *to,
-                            struct samr_UserInfo18 *from);
-void copy_id20_to_sam_passwd(struct samu *to,
-                            struct samr_UserInfo20 *from);
-void copy_id21_to_sam_passwd(const char *log_prefix,
-                            struct samu *to,
-                            struct samr_UserInfo21 *from);
-void copy_id23_to_sam_passwd(struct samu *to,
-                            struct samr_UserInfo23 *from);
-void copy_id24_to_sam_passwd(struct samu *to,
-                            struct samr_UserInfo24 *from);
-void copy_id25_to_sam_passwd(struct samu *to,
-                            struct samr_UserInfo25 *from);
-void copy_id26_to_sam_passwd(struct samu *to,
-                            struct samr_UserInfo26 *from);
-
 /* The following definitions come from rpc_server/srv_spoolss_nt.c  */
 
 void do_drv_upgrade_printer(struct messaging_context *msg,
@@ -5940,8 +5277,8 @@ bool init_service_op_table( void );
 /* The following definitions come from services/services_db.c  */
 
 void svcctl_init_keys( void );
-SEC_DESC *svcctl_get_secdesc( TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN *token );
-bool svcctl_set_secdesc( TALLOC_CTX *ctx, const char *name, SEC_DESC *sec_desc, NT_USER_TOKEN *token );
+struct security_descriptor *svcctl_get_secdesc( TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN *token );
+bool svcctl_set_secdesc( TALLOC_CTX *ctx, const char *name, struct security_descriptor *sec_desc, NT_USER_TOKEN *token );
 const char *svcctl_lookup_dispname(TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN *token );
 const char *svcctl_lookup_description(TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN *token );
 struct regval_ctr *svcctl_fetch_regvalues( const char *name, NT_USER_TOKEN *token );
@@ -6013,29 +5350,6 @@ struct blocking_lock_record *blocking_lock_cancel_smb1(files_struct *fsp,
 
 NTSTATUS change_trust_account_password( const char *domain, const char *remote_machine);
 
-/* The following definitions come from smbd/chgpasswd.c  */
-
-bool chgpasswd(const char *name, const struct passwd *pass,
-              const char *oldpass, const char *newpass, bool as_root);
-bool chgpasswd(const char *name, const struct passwd *pass, 
-              const char *oldpass, const char *newpass, bool as_root);
-bool check_lanman_password(char *user, uchar * pass1,
-                          uchar * pass2, struct samu **hnd);
-bool change_lanman_password(struct samu *sampass, uchar *pass2);
-NTSTATUS pass_oem_change(char *user,
-                        uchar password_encrypted_with_lm_hash[516],
-                        const uchar old_lm_hash_encrypted[16],
-                        uchar password_encrypted_with_nt_hash[516],
-                        const uchar old_nt_hash_encrypted[16],
-                        enum samPwdChangeReason *reject_reason);
-bool password_in_history(uint8_t nt_pw[NT_HASH_LEN],
-                        uint32_t pw_history_len,
-                        const uint8_t *pw_history);
-NTSTATUS check_password_complexity(const char *username,
-                                  const char *password,
-                                  enum samPwdChangeReason *samr_reject_reason);
-NTSTATUS change_oem_password(struct samu *hnd, char *old_passwd, char *new_passwd, bool as_root, enum samPwdChangeReason *samr_reject_reason);
-
 /* The following definitions come from smbd/close.c  */
 
 void set_close_write_time(struct files_struct *fsp, struct timespec ts);
@@ -6486,8 +5800,8 @@ void notify_trigger(struct notify_context *notify,
 
 /* The following definitions come from smbd/ntquotas.c  */
 
-int vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, DOM_SID *psid, SMB_NTQUOTA_STRUCT *qt);
-int vfs_set_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, DOM_SID *psid, SMB_NTQUOTA_STRUCT *qt);
+int vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, struct dom_sid *psid, SMB_NTQUOTA_STRUCT *qt);
+int vfs_set_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, struct dom_sid *psid, SMB_NTQUOTA_STRUCT *qt);
 int vfs_get_user_ntquota_list(files_struct *fsp, SMB_NTQUOTA_LIST **qt_list);
 void *init_quota_handle(TALLOC_CTX *mem_ctx);
 
@@ -6640,6 +5954,7 @@ user_struct *get_partial_auth_user_struct(struct smbd_server_connection *sconn,
 void invalidate_vuid(struct smbd_server_connection *sconn, uint16 vuid);
 void invalidate_all_vuids(struct smbd_server_connection *sconn);
 int register_initial_vuid(struct smbd_server_connection *sconn);
+int register_homes_share(const char *username);
 int register_existing_vuid(struct smbd_server_connection *sconn,
                        uint16 vuid,
                        struct auth_serversupplied_info *server_info,
@@ -6669,24 +5984,24 @@ void reply_pipe_close(connection_struct *conn, struct smb_request *req);
 
 /* The following definitions come from smbd/posix_acls.c  */
 
-void create_file_sids(const SMB_STRUCT_STAT *psbuf, DOM_SID *powner_sid, DOM_SID *pgroup_sid);
+void create_file_sids(const SMB_STRUCT_STAT *psbuf, struct dom_sid *powner_sid, struct dom_sid *pgroup_sid);
 bool nt4_compatible_acls(void);
 uint32_t map_canon_ace_perms(int snum,
                                 enum security_ace_type *pacl_type,
                                 mode_t perms,
                                 bool directory_ace);
-NTSTATUS unpack_nt_owners(connection_struct *conn, uid_t *puser, gid_t *pgrp, uint32 security_info_sent, const SEC_DESC *psd);
+NTSTATUS unpack_nt_owners(connection_struct *conn, uid_t *puser, gid_t *pgrp, uint32 security_info_sent, const struct security_descriptor *psd);
 SMB_ACL_T free_empty_sys_acl(connection_struct *conn, SMB_ACL_T the_acl);
 NTSTATUS posix_fget_nt_acl(struct files_struct *fsp, uint32_t security_info,
-                          SEC_DESC **ppdesc);
+                          struct security_descriptor **ppdesc);
 NTSTATUS posix_get_nt_acl(struct connection_struct *conn, const char *name,
-                         uint32_t security_info, SEC_DESC **ppdesc);
+                         uint32_t security_info, struct security_descriptor **ppdesc);
 int try_chown(connection_struct *conn, struct smb_filename *smb_fname,
              uid_t uid, gid_t gid);
 NTSTATUS append_parent_acl(files_struct *fsp,
-                               const SEC_DESC *pcsd,
-                               SEC_DESC **pp_new_sd);
-NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, const SEC_DESC *psd);
+                               const struct security_descriptor *pcsd,
+                               struct security_descriptor **pp_new_sd);
+NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd);
 int get_acl_group_bits( connection_struct *conn, const char *fname, mode_t *mode );
 int chmod_acl(connection_struct *conn, const char *name, mode_t mode);
 int inherit_access_posix_acl(connection_struct *conn, const char *inherit_from_dir,
@@ -6696,7 +6011,7 @@ bool set_unix_posix_default_acl(connection_struct *conn, const char *fname,
                                const SMB_STRUCT_STAT *psbuf,
                                uint16 num_def_acls, const char *pdata);
 bool set_unix_posix_acl(connection_struct *conn, files_struct *fsp, const char *fname, uint16 num_acls, const char *pdata);
-SEC_DESC *get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fname);
+struct security_descriptor *get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fname);
 
 /* The following definitions come from smbd/process.c  */
 
@@ -7000,6 +6315,7 @@ int sys_statvfs(const char *path, vfs_statvfs_struct *statbuf);
 /* The following definitions come from smbd/trans2.c  */
 
 uint64_t smb_roundup(connection_struct *conn, uint64_t val);
+uint64_t get_FileIndex(connection_struct *conn, const SMB_STRUCT_STAT *psbuf);
 NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
                      files_struct *fsp, const char *fname,
                      const char *ea_name, struct ea_struct *pea);
@@ -7019,8 +6335,10 @@ void send_trans2_replies(connection_struct *conn,
 unsigned char *create_volume_objectid(connection_struct *conn, unsigned char objid[16]);
 NTSTATUS hardlink_internals(TALLOC_CTX *ctx,
                connection_struct *conn,
+               struct smb_request *req,
+               bool overwrite_if_exists,
                const struct smb_filename *smb_fname_old,
-               const struct smb_filename *smb_fname_new);
+               struct smb_filename *smb_fname_new);
 NTSTATUS smb_set_file_time(connection_struct *conn,
                           files_struct *fsp,
                           const struct smb_filename *smb_fname,
@@ -7154,16 +6472,15 @@ NTSTATUS idmap_passdb_init(void);
 
 /* The following definitions come from winbindd/idmap_tdb.c  */
 
-bool idmap_tdb_tdb_close(TDB_CONTEXT *tdbctx);
 NTSTATUS idmap_alloc_tdb_init(void);
 NTSTATUS idmap_tdb_init(void);
 
 /* The following definitions come from winbindd/idmap_util.c  */
 
-NTSTATUS idmap_uid_to_sid(const char *domname, DOM_SID *sid, uid_t uid);
-NTSTATUS idmap_gid_to_sid(const char *domname, DOM_SID *sid, gid_t gid);
-NTSTATUS idmap_sid_to_uid(const char *dom_name, DOM_SID *sid, uid_t *uid);
-NTSTATUS idmap_sid_to_gid(const char *domname, DOM_SID *sid, gid_t *gid);
+NTSTATUS idmap_uid_to_sid(const char *domname, struct dom_sid *sid, uid_t uid);
+NTSTATUS idmap_gid_to_sid(const char *domname, struct dom_sid *sid, gid_t gid);
+NTSTATUS idmap_sid_to_uid(const char *dom_name, struct dom_sid *sid, uid_t *uid);
+NTSTATUS idmap_sid_to_gid(const char *domname, struct dom_sid *sid, gid_t *gid);
 
 /* The following definitions come from winbindd/nss_info.c  */
 
@@ -7193,7 +6510,7 @@ struct tevent_req *fncall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 int fncall_recv(struct tevent_req *req, int *perr);
 
 /* The following definitions come from rpc_server/srv_samr_nt.c */
-NTSTATUS access_check_object( SEC_DESC *psd, NT_USER_TOKEN *token,
+NTSTATUS access_check_object( struct security_descriptor *psd, NT_USER_TOKEN *token,
                                SE_PRIV *rights, uint32 rights_mask,
                                uint32 des_access, uint32 *acc_granted,
                                const char *debug);