Merge of new 2.2 code into HEAD (Gerald I hate you :-) :-). Allows new SAMR
authorJeremy Allison <jra@samba.org>
Sun, 11 Mar 2001 00:32:10 +0000 (00:32 +0000)
committerJeremy Allison <jra@samba.org>
Sun, 11 Mar 2001 00:32:10 +0000 (00:32 +0000)
RPC code to merge with new passdb code.
Currently rpcclient doesn't compile. I'm working on it...
Jeremy.
(This used to be commit 0be41d5158ea4e645e93e8cd30617c038416e549)

86 files changed:
source3/Makefile.in
source3/include/ntdomain.h
source3/include/proto.h
source3/include/rpc_client_proto.h
source3/include/rpc_lsa.h
source3/include/rpc_samr.h
source3/include/rpc_srvsvc.h
source3/lib/bitmap.c
source3/lib/charcnv.c
source3/lib/debug.c
source3/lib/messages.c
source3/lib/msrpc_use.c
source3/lib/slprintf.c
source3/lib/util.c
source3/libsmb/cli_samr.c
source3/locking/brlock.c
source3/locking/locking.c
source3/passdb/passdb.c
source3/printing/load.c
source3/printing/nt_printing.c
source3/printing/printfsp.c
source3/printing/printing.c
source3/rpc_client/cli_samr.c
source3/rpc_parse/parse_dfs.c
source3/rpc_parse/parse_lsa.c
source3/rpc_parse/parse_net.c
source3/rpc_parse/parse_samr.c
source3/rpc_parse/parse_spoolss.c
source3/rpc_parse/parse_srv.c
source3/rpc_server/srv_lsa.c
source3/rpc_server/srv_lsa_hnd.c
source3/rpc_server/srv_lsa_nt.c
source3/rpc_server/srv_netlog.c
source3/rpc_server/srv_netlog_nt.c
source3/rpc_server/srv_pipe.c
source3/rpc_server/srv_pipe_hnd.c
source3/rpc_server/srv_reg.c
source3/rpc_server/srv_reg_nt.c
source3/rpc_server/srv_samr.c
source3/rpc_server/srv_samr_nt.c
source3/rpc_server/srv_spoolss.c
source3/rpc_server/srv_spoolss_nt.c
source3/rpc_server/srv_srvsvc.c
source3/rpc_server/srv_srvsvc_nt.c
source3/rpc_server/srv_util.c
source3/rpc_server/srv_wkssvc.c
source3/rpc_server/srv_wkssvc_nt.c
source3/rpcclient/cmd_samr.c
source3/smbd/blocking.c
source3/smbd/chgpasswd.c
source3/smbd/close.c
source3/smbd/conn.c
source3/smbd/dir.c
source3/smbd/dosmode.c
source3/smbd/error.c
source3/smbd/fileio.c
source3/smbd/filename.c
source3/smbd/files.c
source3/smbd/ipc.c
source3/smbd/lanman.c
source3/smbd/message.c
source3/smbd/negprot.c
source3/smbd/notify.c
source3/smbd/notify_hash.c
source3/smbd/notify_kernel.c
source3/smbd/nttrans.c
source3/smbd/open.c
source3/smbd/oplock.c
source3/smbd/oplock_irix.c
source3/smbd/oplock_linux.c
source3/smbd/password.c
source3/smbd/pipes.c
source3/smbd/posix_acls.c
source3/smbd/process.c
source3/smbd/reply.c
source3/smbd/sec_ctx.c
source3/smbd/server.c
source3/smbd/service.c
source3/smbd/trans2.c
source3/smbd/uid.c
source3/smbd/vfs-wrap.c
source3/smbd/vfs.c
source3/utils/smbpasswd.c
source3/utils/status.c
source3/web/cgi.c
source3/web/swat.c

index a6e8dd32d9d358f5eb1b232a8c7527809a51e79c..c088602baa7cc1ae724ee43366353bc7d7094808 100644 (file)
@@ -129,12 +129,12 @@ LIBMSRPC_OBJ = libsmb/cli_lsarpc.o libsmb/cli_samr.o libsmb/cli_spoolss.o \
                rpc_client/cli_pipe.o
 
 RPC_SERVER_OBJ = rpc_server/srv_lsa.o rpc_server/srv_lsa_nt.o \
-                 rpc_server/srv_lsa_hnd.o rpc_server/srv_netlog.o \
+                 rpc_server/srv_lsa_hnd.o rpc_server/srv_netlog.o rpc_server/srv_netlog_nt.o \
                  rpc_server/srv_pipe_hnd.o rpc_server/srv_reg.o rpc_server/srv_reg_nt.o \
-                 rpc_server/srv_samr.o rpc_server/srv_srvsvc.o rpc_server/srv_srvsvc_nt.o \
+                 rpc_server/srv_samr.o rpc_server/srv_samr_nt.o rpc_server/srv_srvsvc.o rpc_server/srv_srvsvc_nt.o \
                  rpc_server/srv_util.o rpc_server/srv_wkssvc.o rpc_server/srv_wkssvc_nt.o \
                  rpc_server/srv_pipe.o rpc_server/srv_dfs.o rpc_server/srv_dfs_nt.o \
-                rpc_server/srv_spoolss.o rpc_server/srv_spoolss_nt.o
+                 rpc_server/srv_spoolss.o rpc_server/srv_spoolss_nt.o
 
 # this includes only the low level parse code, not stuff
 # that requires knowledge of security contexts
@@ -150,7 +150,7 @@ RPC_PARSE_OBJ = rpc_parse/parse_lsa.o rpc_parse/parse_net.o \
 
 RPC_PARSE_NEW_OBJ = rpc_parse/parse_lsa.o rpc_parse/parse_net.o \
                 rpc_parse/parse_reg.o rpc_parse/parse_rpc.o \
-                rpc_parse/parse_srv.o rpc_parse/parse_samr_new.o \
+                rpc_parse/parse_srv.o \
                 rpc_parse/parse_wks.o \
                rpc_parse/parse_spoolss.o rpc_parse/parse_dfs.o \
                rpc_parse/parse_creds.o
index 0ae48169fbd5c2c8fb3bd4d012febdc1b71763db..a3fd51948ddc220b2f987056312bf4664c2b9480 100644 (file)
@@ -152,6 +152,27 @@ struct msrpc_state
     uint32 pid;
 };
 
+/*
+ * Handle database - stored per pipe.
+ */
+
+struct policy
+{
+    struct policy *next, *prev;
+    struct pipes_struct *p;
+
+    POLICY_HND pol_hnd;
+
+    void *data_ptr;
+    void (*free_fn)(void *);
+
+};
+
+struct handle_list {
+       struct policy *Policy;
+       size_t count;
+};
+
 typedef struct pipes_struct
 {
        struct pipes_struct *next, *prev;
@@ -224,6 +245,10 @@ typedef struct pipes_struct
 
        /* talloc context to use when allocating memory on this pipe. */
        TALLOC_CTX *mem_ctx;
+
+       /* handle database to use on this pipe. */
+       struct handle_list pipe_handles;
+
 } pipes_struct;
 
 struct api_struct
@@ -265,11 +290,7 @@ struct acct_info
 #include "rpc_lsa.h"
 #include "rpc_netlogon.h"
 #include "rpc_reg.h"
-#if OLD_NTDOMAIN
-#include "rpc_samr_old.h"
-#else
 #include "rpc_samr.h"
-#endif
 #include "rpc_srvsvc.h"
 #include "rpc_wkssvc.h"
 #include "rpc_spoolss.h"
index 3a889ef7e9d9fb56fcaddf324396bc5609793721..6f37f8ffc9880f0ecc5b930a04dc2b8d74c9e4fe 100644 (file)
@@ -26,6 +26,7 @@ BOOL check_access(int sock, char *allow_list, char *deny_list);
 /*The following definitions come from  lib/bitmap.c  */
 
 struct bitmap *bitmap_allocate(int n);
+void bitmap_free(struct bitmap *bm);
 BOOL bitmap_set(struct bitmap *bm, unsigned i);
 BOOL bitmap_clear(struct bitmap *bm, unsigned i);
 BOOL bitmap_query(struct bitmap *bm, unsigned i);
@@ -178,7 +179,6 @@ BOOL msrpc_establish_connection(struct msrpc_state *msrpc,
 
 /*The following definitions come from  lib/msrpc_use.c  */
 
-#if OLD_NTDOMAIN
 void init_msrpc_use(void);
 void free_msrpc_use(void);
 struct msrpc_state *msrpc_use_add(const char* pipe_name,
@@ -190,7 +190,6 @@ BOOL msrpc_use_del(const char* pipe_name,
                                BOOL force_close,
                                BOOL *connection_closed);
 void msrpc_net_use_enum(uint32 *num_cons, struct use_info ***use);
-#endif
 
 /*The following definitions come from  lib/pidfile.c  */
 
@@ -218,870 +217,868 @@ void CatchChildLeaveStatus(void);
 
 int vslprintf(char *str, int n, char *format, va_list ap);
 
-/*The following definitions come from  libsmb/cliconnect.c  */
+/*The following definitions come from  lib/smbrun.c  */
 
-BOOL cli_session_setup(struct cli_state *cli, 
-                      char *user, 
-                      char *pass, int passlen,
-                      char *ntpass, int ntpasslen,
-                      char *workgroup);
-BOOL cli_ulogoff(struct cli_state *cli);
-BOOL cli_send_tconX(struct cli_state *cli, 
-                   char *share, char *dev, char *pass, int passlen);
-BOOL cli_tdis(struct cli_state *cli);
-void cli_negprot_send(struct cli_state *cli);
-BOOL cli_negprot(struct cli_state *cli);
-BOOL cli_session_request(struct cli_state *cli,
-                        struct nmb_name *calling, struct nmb_name *called);
-BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip);
-BOOL cli_reestablish_connection(struct cli_state *cli);
-BOOL cli_establish_connection(struct cli_state *cli, 
-                               char *dest_host, struct in_addr *dest_ip,
-                               struct nmb_name *calling, struct nmb_name *called,
-                               char *service, char *service_type,
-                               BOOL do_shutdown, BOOL do_tcon);
-BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost, char *desthost,
-                                     struct in_addr *pdest_ip);
+int smbrun(char *cmd,char *outfile,BOOL shared);
 
-/*The following definitions come from  libsmb/clidgram.c  */
+/*The following definitions come from  lib/snprintf.c  */
 
-int cli_send_mailslot(int dgram_sock, BOOL unique, char *mailslot, 
-                     char *buf, int len,
-                     const char *srcname, int src_type, 
-                     const char *dstname, int dest_type,
-                     struct in_addr dest_ip, struct in_addr src_ip,
-                     int dest_port, int src_port);
-int cli_get_response(int dgram_sock, BOOL unique, char *mailslot, char *buf, int bufsiz);
-int cli_get_backup_list(const char *myname, const char *send_to_name);
-int cli_get_backup_server(char *my_name, char *target, char *servername, int namesize);
 
-/*The following definitions come from  libsmb/clientgen.c  */
+/*The following definitions come from  lib/substitute.c  */
 
-int cli_set_port(struct cli_state *cli, int port);
-BOOL cli_receive_smb(struct cli_state *cli);
-BOOL cli_send_smb(struct cli_state *cli);
-void cli_setup_packet(struct cli_state *cli);
-void cli_setup_bcc(struct cli_state *cli, void *p);
-void cli_init_creds(struct cli_state *cli, const struct ntuser_creds *usr);
-struct cli_state *cli_initialise(struct cli_state *cli);
-void cli_shutdown(struct cli_state *cli);
-void cli_sockopt(struct cli_state *cli, char *options);
-uint16 cli_setpid(struct cli_state *cli, uint16 pid);
+void standard_sub_basic(char *str);
+void standard_sub_advanced(int snum, char *user, char *connectpath, gid_t gid, char *str);
+void standard_sub_conn(connection_struct *conn, char *str);
+void standard_sub_snum(int snum, char *str);
+void standard_sub_vuser(char *str, user_struct *vuser);
+void standard_sub_vsnum(char *str, user_struct *vuser, int snum);
 
-/*The following definitions come from  libsmb/clierror.c  */
+/*The following definitions come from  lib/sysacls.c  */
 
-char *cli_errstr(struct cli_state *cli);
-int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_error);
+int sys_acl_get_entry( SMB_ACL_T the_acl, int entry_id, SMB_ACL_ENTRY_T *entry_p);
+int sys_acl_get_tag_type( SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p);
+int sys_acl_get_permset( SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p);
+void *sys_acl_get_qualifier( SMB_ACL_ENTRY_T entry_d);
+SMB_ACL_T sys_acl_get_file( const char *path_p, SMB_ACL_TYPE_T type);
+SMB_ACL_T sys_acl_get_fd(int fd);
+int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset);
+int sys_acl_add_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm);
+int sys_acl_get_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm);
+char *sys_acl_to_text( SMB_ACL_T the_acl, ssize_t *plen);
+SMB_ACL_T sys_acl_init( int count);
+int sys_acl_create_entry( SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry);
+int sys_acl_set_tag_type( SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype);
+int sys_acl_set_qualifier( SMB_ACL_ENTRY_T entry, void *qual);
+int sys_acl_set_permset( SMB_ACL_ENTRY_T entry, SMB_ACL_PERMSET_T permset);
+int sys_acl_valid( SMB_ACL_T theacl );
+int sys_acl_set_file( char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl);
+int sys_acl_set_fd( int fd, SMB_ACL_T theacl);
+int sys_acl_free_text(char *text);
+int sys_acl_free_acl(SMB_ACL_T the_acl) ;
+int sys_acl_get_entry(SMB_ACL_T acl_d, int entry_id, SMB_ACL_ENTRY_T *entry_p);
+int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *type_p);
+int sys_acl_get_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p);
+void *sys_acl_get_qualifier(SMB_ACL_ENTRY_T entry_d);
+SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type);
+SMB_ACL_T sys_acl_get_fd(int fd);
+int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d);
+int sys_acl_add_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm);
+int sys_acl_get_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm);
+char *sys_acl_to_text(SMB_ACL_T acl_d, ssize_t *len_p);
+SMB_ACL_T sys_acl_init(int count);
+int sys_acl_create_entry(SMB_ACL_T *acl_p, SMB_ACL_ENTRY_T *entry_p);
+int sys_acl_set_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T tag_type);
+int sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry_d, void *qual_p);
+int sys_acl_set_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T permset_d);
+int sys_acl_valid(SMB_ACL_T acl_d);
+int sys_acl_set_file(char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
+int sys_acl_set_fd(int fd, SMB_ACL_T acl_d);
+int sys_acl_free_text(char *text);
+int sys_acl_free_acl(SMB_ACL_T acl_d) ;
+int sys_acl_get_entry(SMB_ACL_T acl_d, int entry_id, SMB_ACL_ENTRY_T *entry_p);
+int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *type_p);
+int sys_acl_get_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p);
+void *sys_acl_get_qualifier(SMB_ACL_ENTRY_T entry_d);
+SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type);
+SMB_ACL_T sys_acl_get_fd(int fd);
+int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d);
+int sys_acl_add_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm);
+int sys_acl_get_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm);
+char *sys_acl_to_text(SMB_ACL_T acl_d, ssize_t *len_p);
+SMB_ACL_T sys_acl_init(int count);
+int sys_acl_create_entry(SMB_ACL_T *acl_p, SMB_ACL_ENTRY_T *entry_p);
+int sys_acl_set_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T tag_type);
+int sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry_d, void *qual_p);
+int sys_acl_set_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T permset_d);
+int sys_acl_valid(SMB_ACL_T acl_d);
+int sys_acl_set_file(char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
+int sys_acl_set_fd(int fd, SMB_ACL_T acl_d);
+int sys_acl_free_text(char *text);
+int sys_acl_free_acl(SMB_ACL_T acl_d) ;
+int sys_acl_get_entry( SMB_ACL_T the_acl, int entry_id, SMB_ACL_ENTRY_T *entry_p);
+int sys_acl_get_tag_type( SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p);
+int sys_acl_get_permset( SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p);
+void *sys_acl_get_qualifier( SMB_ACL_ENTRY_T entry_d);
+SMB_ACL_T sys_acl_get_file( const char *path_p, SMB_ACL_TYPE_T type);
+SMB_ACL_T sys_acl_get_fd(int fd);
+int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset);
+int sys_acl_add_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm);
+int sys_acl_get_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm);
+char *sys_acl_to_text( SMB_ACL_T the_acl, ssize_t *plen);
+int sys_acl_free_text(char *text);
+SMB_ACL_T sys_acl_init( int count);
+int sys_acl_create_entry( SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry);
+int sys_acl_set_tag_type( SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype);
+int sys_acl_set_qualifier( SMB_ACL_ENTRY_T entry, void *qual);
+int sys_acl_set_permset( SMB_ACL_ENTRY_T entry, SMB_ACL_PERMSET_T permset);
+int sys_acl_valid( SMB_ACL_T theacl );
+int sys_acl_set_file( char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl);
+int sys_acl_set_fd( int fd, SMB_ACL_T theacl);
+int sys_acl_free_acl(SMB_ACL_T the_acl) ;
 
-/*The following definitions come from  libsmb/clifile.c  */
+/*The following definitions come from  lib/system.c  */
 
-BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst);
-BOOL cli_unlink(struct cli_state *cli, char *fname);
-BOOL cli_mkdir(struct cli_state *cli, char *dname);
-BOOL cli_rmdir(struct cli_state *cli, char *dname);
-int cli_nt_create(struct cli_state *cli, char *fname, uint32 DesiredAccess);
-int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode);
-BOOL cli_close(struct cli_state *cli, int fnum);
-BOOL cli_lock(struct cli_state *cli, int fnum, 
-             uint32 offset, uint32 len, int timeout, enum brl_type lock_type);
-BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len);
-BOOL cli_lock64(struct cli_state *cli, int fnum, 
-               SMB_BIG_UINT offset, SMB_BIG_UINT len, int timeout, enum brl_type lock_type);
-BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_UINT len);
-BOOL cli_getattrE(struct cli_state *cli, int fd, 
-                 uint16 *attr, size_t *size, 
-                 time_t *c_time, time_t *a_time, time_t *m_time);
-BOOL cli_getatr(struct cli_state *cli, char *fname, 
-               uint16 *attr, size_t *size, time_t *t);
-BOOL cli_setatr(struct cli_state *cli, char *fname, uint16 attr, time_t t);
-BOOL cli_chkpath(struct cli_state *cli, char *path);
-BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
+int sys_usleep(long usecs);
+int sys_stat(const char *fname,SMB_STRUCT_STAT *sbuf);
+int sys_fstat(int fd,SMB_STRUCT_STAT *sbuf);
+int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf);
+int sys_ftruncate(int fd, SMB_OFF_T offset);
+SMB_OFF_T sys_lseek(int fd, SMB_OFF_T offset, int whence);
+int sys_fseek(FILE *fp, SMB_OFF_T offset, int whence);
+SMB_OFF_T sys_ftell(FILE *fp);
+int sys_creat(const char *path, mode_t mode);
+int sys_open(const char *path, int oflag, mode_t mode);
+FILE *sys_fopen(const char *path, const char *type);
+SMB_STRUCT_DIRENT *sys_readdir(DIR *dirp);
+int sys_waitpid(pid_t pid,int *status,int options);
+char *sys_getwd(char *s);
+int sys_chown(const char *fname,uid_t uid,gid_t gid);
+int sys_chroot(const char *dname);
+struct hostent *sys_gethostbyname(const char *name);
+void oplock_set_capability(BOOL this_process, BOOL inherit);
+long sys_random(void);
+void sys_srandom(unsigned int seed);
+int groups_max(void);
+int sys_getgroups(int setlen, gid_t *gidset);
+int sys_setgroups(int setlen, gid_t *gidset);
+void sys_setpwent(void);
+struct passwd *sys_getpwent(void);
+void sys_endpwent(void);
+struct passwd *sys_getpwnam(const char *name);
+struct passwd *sys_getpwuid(uid_t uid);
+int wsys_stat(const smb_ucs2_t *wfname,SMB_STRUCT_STAT *sbuf);
+int wsys_lstat(const smb_ucs2_t *wfname,SMB_STRUCT_STAT *sbuf);
+int wsys_creat(const smb_ucs2_t *wfname, mode_t mode);
+int wsys_open(const smb_ucs2_t *wfname, int oflag, mode_t mode);
+FILE *wsys_fopen(const smb_ucs2_t *wfname, const char *type);
+DIR *wsys_opendir(const smb_ucs2_t *wfname);
+smb_ucs2_t *wsys_getwd(smb_ucs2_t *s);
+int wsys_chown(const smb_ucs2_t *wfname, uid_t uid, gid_t gid);
+int wsys_chroot(const smb_ucs2_t *wfname);
+pid_t sys_fork(void);
+pid_t sys_getpid(void);
+int sys_popen(const char *command);
+int sys_pclose(int fd);
 
-/*The following definitions come from  libsmb/clilist.c  */
+/*The following definitions come from  lib/talloc.c  */
 
-int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute, 
-                void (*fn)(file_info *, const char *, void *), void *state);
-int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, 
-                void (*fn)(file_info *, const char *, void *), void *state);
-int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, 
-            void (*fn)(file_info *, const char *, void *), void *state);
+TALLOC_CTX *talloc_init(void);
+void *talloc(TALLOC_CTX *t, size_t size);
+void talloc_destroy_pool(TALLOC_CTX *t);
+void talloc_destroy(TALLOC_CTX *t);
+size_t talloc_pool_size(TALLOC_CTX *t);
+void *talloc_zero(TALLOC_CTX *t, size_t size);
+void *talloc_memdup(TALLOC_CTX *t, void *p, size_t size);
 
-/*The following definitions come from  libsmb/cli_lsarpc.c  */
+/*The following definitions come from  lib/time.c  */
 
-struct cli_state *cli_lsa_initialise(struct cli_state *cli, char *system_name,
-                                    struct ntuser_creds *creds);
-void cli_lsa_shutdown(struct cli_state *cli);
-uint32 cli_lsa_open_policy(struct cli_state *cli, BOOL sec_qos, 
-                          uint32 des_access, POLICY_HND *pol);
-uint32 cli_lsa_close(struct cli_state *cli, POLICY_HND *pol);
-uint32 cli_lsa_lookup_sids(struct cli_state *cli, POLICY_HND *pol,
-                          int num_sids, DOM_SID *sids, char ***names, 
-                          uint32 **types, int *num_names);
-uint32 cli_lsa_lookup_names(struct cli_state *cli, POLICY_HND *pol,
-                           int num_names, char **names, DOM_SID **sids,
-                           uint32 **types, int *num_sids);
-uint32 cli_lsa_query_info_policy(struct cli_state *cli, POLICY_HND *pol, 
-                                uint16 info_class, fstring domain_name, 
-                                DOM_SID * domain_sid);
-uint32 cli_lsa_enum_trust_dom(struct cli_state *cli, POLICY_HND *pol, 
-                             uint32 *enum_ctx, uint32 *num_domains,
-                             char ***domain_names, DOM_SID **domain_sids);
+void GetTimeOfDay(struct timeval *tval);
+void TimeInit(void);
+int TimeDiff(time_t t);
+struct tm *LocalTime(time_t *t);
+time_t nt_time_to_unix(NTTIME *nt);
+time_t interpret_long_date(char *p);
+void unix_to_nt_time(NTTIME *nt, time_t t);
+void put_long_date(char *p,time_t t);
+BOOL null_mtime(time_t mtime);
+void put_dos_date(char *buf,int offset,time_t unixdate);
+void put_dos_date2(char *buf,int offset,time_t unixdate);
+void put_dos_date3(char *buf,int offset,time_t unixdate);
+time_t make_unix_date(void *date_ptr);
+time_t make_unix_date2(void *date_ptr);
+time_t make_unix_date3(void *date_ptr);
+char *http_timestring(time_t t);
+char *timestring(BOOL hires);
+time_t get_create_time(SMB_STRUCT_STAT *st,BOOL fake_dirs);
 
-/*The following definitions come from  libsmb/climessage.c  */
-
-BOOL cli_message_start(struct cli_state *cli, char *host, char *username, 
-                             int *grp);
-BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp);
-BOOL cli_message_end(struct cli_state *cli, int grp);
-
-/*The following definitions come from  libsmb/cliprint.c  */
+/*The following definitions come from  lib/ufc.c  */
 
-int cli_print_queue(struct cli_state *cli, 
-                   void (*fn)(struct print_job_info *));
-int cli_printjob_del(struct cli_state *cli, int job);
+char *ufc_crypt(char *key,char *salt);
 
-/*The following definitions come from  libsmb/clirap.c  */
+/*The following definitions come from  lib/username.c  */
 
-BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, 
-                  uint16 *setup, uint32 setup_count, uint32 max_setup_count,
-                  char *params, uint32 param_count, uint32 max_param_count,
-                  char *data, uint32 data_count, uint32 max_data_count,
-                  char **rparam, uint32 *rparam_count,
-                  char **rdata, uint32 *rdata_count);
-BOOL cli_api(struct cli_state *cli,
-            char *param, int prcnt, int mprcnt,
-            char *data, int drcnt, int mdrcnt,
-            char **rparam, int *rprcnt,
-            char **rdata, int *rdrcnt);
-BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation);
-int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *, void *), void *state);
-BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
-                      void (*fn)(const char *, uint32, const char *, void *),
-                      void *state);
-BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password,
-                             const char *old_password);
-BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, 
-                  time_t *c_time, time_t *a_time, time_t *m_time, 
-                  size_t *size, uint16 *mode);
-BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, 
-                   time_t *c_time, time_t *a_time, time_t *m_time, 
-                   time_t *w_time, size_t *size, uint16 *mode,
-                   SMB_INO_T *ino);
-BOOL cli_qfileinfo(struct cli_state *cli, int fnum, 
-                  uint16 *mode, size_t *size,
-                  time_t *c_time, time_t *a_time, time_t *m_time, 
-                  time_t *w_time, SMB_INO_T *ino);
+char *get_user_home_dir(char *user);
+BOOL map_username(char *user);
+struct passwd *Get_Pwnam(char *user,BOOL allow_change);
+BOOL user_in_group_list(char *user,char *gname);
+BOOL user_in_list(char *user,char *list);
+struct passwd *smb_getpwnam(char *user, BOOL allow_change);
 
-/*The following definitions come from  libsmb/clireadwrite.c  */
+/*The following definitions come from  lib/util.c  */
 
-size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size);
-ssize_t cli_write(struct cli_state *cli,
-                 int fnum, uint16 write_mode,
-                 char *buf, off_t offset, size_t size);
-ssize_t cli_smbwrite(struct cli_state *cli,
-                    int fnum, char *buf, off_t offset, size_t size1);
+char *tmpdir(void);
+BOOL in_group(gid_t group, gid_t current_gid, int ngroups, gid_t *groups);
+char *Atoic(char *p, int *n, char *c);
+char *get_numlist(char *p, uint32 **num, int *count);
+BOOL file_exist(char *fname,SMB_STRUCT_STAT *sbuf);
+int file_rename(char *from, char *to);
+time_t file_modtime(char *fname);
+BOOL directory_exist(char *dname,SMB_STRUCT_STAT *st);
+SMB_OFF_T get_file_size(char *file_name);
+char *attrib_string(uint16 mode);
+void show_msg(char *buf);
+void smb_setlen(char *buf,int len);
+int set_message(char *buf,int num_words,int num_bytes,BOOL zero);
+void set_message_bcc(char *buf,int num_bytes);
+void set_message_end(void *outbuf,void *end_ptr);
+void dos_clean_name(char *s);
+void unix_clean_name(char *s);
+void make_dir_struct(char *buf,char *mask,char *fname,SMB_OFF_T size,int mode,time_t date);
+void close_low_fds(void);
+int set_blocking(int fd, BOOL set);
+SMB_OFF_T transfer_file(int infd,int outfd,SMB_OFF_T n,char *header,int headlen,int align);
+void msleep(int t);
+void become_daemon(void);
+BOOL yesno(char *p);
+void *Realloc(void *p,size_t size);
+void safe_free(void *p);
+BOOL get_myname(char *my_name);
+int interpret_protocol(char *str,int def);
+BOOL is_ipaddress(const char *str);
+uint32 interpret_addr(char *str);
+struct in_addr *interpret_addr2(char *str);
+BOOL zero_ip(struct in_addr ip);
+BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
+struct hostent *Get_Hostbyname(const char *name);
+BOOL process_exists(pid_t pid);
+char *uidtoname(uid_t uid);
+char *gidtoname(gid_t gid);
+uid_t nametouid(char *name);
+gid_t nametogid(char *name);
+void smb_panic(char *why);
+char *readdirname(DIR *p);
+BOOL is_in_path(char *name, name_compare_entry *namelist);
+void set_namearray(name_compare_entry **ppname_array, char *namelist);
+void free_namearray(name_compare_entry *name_array);
+BOOL fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
+BOOL is_myname(char *s);
+void set_remote_arch(enum remote_arch_types type);
+enum remote_arch_types get_remote_arch(void);
+void out_ascii(FILE *f, unsigned char *buf,int len);
+void out_data(FILE *f,char *buf1,int len, int per_line);
+void print_asc(int level, unsigned char *buf,int len);
+void dump_data(int level,char *buf1,int len);
+char *tab_depth(int depth);
+int str_checksum(const char *s);
+void zero_free(void *p, size_t size);
+int set_maxfiles(int requested_max);
+BOOL reg_split_key(char *full_keyname, uint32 *reg_type, char *key_name);
+char *smbd_mktemp(char *template);
+void *memdup(void *p, size_t size);
+char *myhostname(void);
+char *lock_path(char *name);
+char *parent_dirname(const char *path);
+BOOL ms_has_wild(char *s);
+BOOL mask_match(char *string, char *pattern, BOOL is_case_sensitive);
+int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6);
 
-/*The following definitions come from  libsmb/cli_samr.c  */
+/*The following definitions come from  lib/util_array.c  */
 
-#if NEW_NTDOMAIN
-struct cli_state *cli_samr_initialise(struct cli_state *cli, char *system_name,
-                                     struct ntuser_creds *creds);
-void cli_samr_shutdown(struct cli_state *cli);
-uint32 cli_samr_connect(struct cli_state *cli, char *srv_name,
-                       uint32 access_mask, POLICY_HND *connect_pol);
-uint32 cli_samr_close(struct cli_state *cli, POLICY_HND *connect_pol);
-uint32 cli_samr_open_domain(struct cli_state *cli, POLICY_HND *connect_pol,
-                           uint32 access_mask, DOM_SID *domain_sid,
-                           POLICY_HND *domain_pol);
-uint32 cli_samr_open_user(struct cli_state *cli, POLICY_HND *domain_pol,
-                         uint32 access_mask, uint32 user_rid,
-                         POLICY_HND *user_pol);
-uint32 cli_samr_open_group(struct cli_state *cli, POLICY_HND *domain_pol,
-                         uint32 access_mask, uint32 group_rid,
-                         POLICY_HND *group_pol);
-uint32 cli_samr_query_userinfo(struct cli_state *cli, POLICY_HND *user_pol, 
-                              uint16 switch_value, SAM_USERINFO_CTR *ctr);
-uint32 cli_samr_query_groupinfo(struct cli_state *cli, POLICY_HND *group_pol,
-                               uint32 info_level, GROUP_INFO_CTR *ctr);
-uint32 cli_samr_query_usergroups(struct cli_state *cli, POLICY_HND *user_pol,
-                                uint32 *num_groups, DOM_GID **gid);
-uint32 cli_samr_query_groupmem(struct cli_state *cli, POLICY_HND *group_pol,
-                              uint32 *num_mem, uint32 **rid, uint32 **attr);
-#endif
+void free_void_array(uint32 num_entries, void **entries,
+               void(free_item)(void*));
+void* add_copy_to_array(uint32 *len, void ***array, const void *item,
+       void*(item_dup)(const void*), BOOL alloc_anyway);
+void* add_item_to_array(uint32 *len, void ***array, void *item);
+void free_use_info_array(uint32 num_entries, struct use_info **entries);
+struct use_info* add_use_info_to_array(uint32 *len, struct use_info ***array,
+                               const struct use_info *name);
+void free_char_array(uint32 num_entries, char **entries);
+char* add_chars_to_array(uint32 *len, char ***array, const char *name);
+void free_uint32_array(uint32 num_entries, uint32 **entries);
+uint32* add_uint32s_to_array(uint32 *len, uint32 ***array, const uint32 *name);
+void free_sid_array(uint32 num_entries, DOM_SID **entries);
+DOM_SID* add_sid_to_array(uint32 *len, DOM_SID ***array, const DOM_SID *sid);
 
-/*The following definitions come from  libsmb/clisecdesc.c  */
+/*The following definitions come from  lib/util_file.c  */
 
-SEC_DESC *cli_query_secdesc(struct cli_state *cli,int fd);
-BOOL cli_set_secdesc(struct cli_state *cli,int fd, SEC_DESC *sd);
+BOOL do_file_lock(int fd, int waitsecs, int type);
+BOOL file_lock(int fd, int type, int secs, int *plock_depth);
+BOOL file_unlock(int fd, int *plock_depth);
+void *startfilepwent(char *pfile, char *s_readbuf, int bufsize,
+                               int *file_lock_depth, BOOL update);
+void endfilepwent(void *vp, int *file_lock_depth);
+SMB_BIG_UINT getfilepwpos(void *vp);
+BOOL setfilepwpos(void *vp, SMB_BIG_UINT tok);
+int getfileline(void *vp, char *linebuf, int linebuf_size);
+char *fgets_slash(char *s2,int maxlen,FILE *f);
+char *file_pload(char *syscmd, size_t *size);
+char *file_load(char *fname, size_t *size);
+char **file_lines_load(char *fname, int *numlines, BOOL convert);
+char **file_lines_pload(char *syscmd, int *numlines, BOOL convert);
+void file_lines_free(char **lines);
+void file_lines_slashcont(char **lines);
 
-/*The following definitions come from  libsmb/cli_spoolss.c  */
+/*The following definitions come from  lib/util_list.c  */
 
-struct cli_state *cli_spoolss_initialise(struct cli_state *cli, 
-                                        char *system_name,
-                                        struct ntuser_creds *creds);
-void cli_spoolss_shutdown(struct cli_state *cli);
-uint32 cli_spoolss_open_printer_ex(struct cli_state *cli, char *printername,
-                                  char *datatype, uint32 access_required,
-                                  char *station, char *username,
-                                  POLICY_HND *pol);
-uint32 cli_spoolss_closeprinter(struct cli_state *cli, POLICY_HND *pol);
-uint32 cli_spoolss_enum_printers(struct cli_state *cli, uint32 flags,
-                                uint32 level, int *returned, 
-                                PRINTER_INFO_CTR *ctr);
-uint32 cli_spoolss_enum_ports(struct cli_state *cli, uint32 level, 
-                             int *returned, PORT_INFO_CTR *ctr);
-uint32 cli_spoolss_getprinter(struct cli_state *cli, POLICY_HND *pol,
-                             uint32 level, PRINTER_INFO_CTR *ctr);
+BOOL copy_policy_hnd (POLICY_HND *dest, const POLICY_HND *src);
+BOOL compare_rpc_hnd_node(const RPC_HND_NODE *x, 
+                         const RPC_HND_NODE *y);
+BOOL RpcHndList_set_connection(const POLICY_HND *hnd, 
+                              struct cli_connection *con);
+BOOL RpcHndList_del_connection(const POLICY_HND *hnd);
+struct cli_connection* RpcHndList_get_connection(const POLICY_HND *hnd);
 
-/*The following definitions come from  libsmb/clistr.c  */
+/*The following definitions come from  lib/util_seaccess.c  */
 
-int clistr_push(struct cli_state *cli, void *dest, const char *src, int dest_len, int flags);
-int clistr_push_size(struct cli_state *cli, const void *dest, const char *src, int dest_len, int flags);
-int clistr_pull(struct cli_state *cli, char *dest, const void *src, int dest_len, int src_len, int flags);
-int clistr_pull_size(struct cli_state *cli, const void *src, int src_len);
-int clistr_align(struct cli_state *cli, int offset);
+void se_map_generic(uint32 *access_mask, struct generic_mapping *mapping);
+BOOL se_access_check(SEC_DESC *sd, struct current_user *user,
+                    uint32 acc_desired, uint32 *acc_granted, uint32 *status);
+SEC_DESC_BUF *se_create_child_secdesc(TALLOC_CTX *ctx, SEC_DESC *parent_ctr, 
+                                     BOOL child_container);
 
-/*The following definitions come from  libsmb/clitrans.c  */
+/*The following definitions come from  lib/util_sec.c  */
 
-BOOL cli_send_trans(struct cli_state *cli, int trans, 
-                   char *pipe_name, 
-                   int fid, int flags,
-                   uint16 *setup, int lsetup, int msetup,
-                   char *param, int lparam, int mparam,
-                   char *data, int ldata, int mdata);
-BOOL cli_receive_trans(struct cli_state *cli,int trans,
-                              char **param, int *param_len,
-                              char **data, int *data_len);
-BOOL cli_send_nt_trans(struct cli_state *cli, 
-                      int function, 
-                      int flags,
-                      uint16 *setup, int lsetup, int msetup,
-                      char *param, int lparam, int mparam,
-                      char *data, int ldata, int mdata);
-BOOL cli_receive_nt_trans(struct cli_state *cli,
-                         char **param, int *param_len,
-                         char **data, int *data_len);
+void gain_root_privilege(void);
+void gain_root_group_privilege(void);
+void set_effective_uid(uid_t uid);
+void set_effective_gid(gid_t gid);
+void save_re_uid(void);
+void restore_re_uid(void);
+int set_re_uid(void);
+void become_user_permanently(uid_t uid, gid_t gid);
 
-/*The following definitions come from  libsmb/credentials.c  */
+/*The following definitions come from  lib/util_sid.c  */
 
-char *credstr(uchar *cred);
-void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, char *pass, 
-                     uchar session_key[8]);
-void cred_create(uchar session_key[8], DOM_CHAL *stor_cred, UTIME timestamp, 
-                DOM_CHAL *cred);
-int cred_assert(DOM_CHAL *cred, uchar session_key[8], DOM_CHAL *stored_cred,
-               UTIME timestamp);
-BOOL clnt_deal_with_creds(uchar sess_key[8],
-                         DOM_CRED *sto_clnt_cred, DOM_CRED *rcv_srv_cred);
-BOOL deal_with_creds(uchar sess_key[8],
-                    DOM_CRED *sto_clnt_cred, 
-                    DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred);
-
-/*The following definitions come from  libsmb/namequery.c  */
-
-struct node_status *name_status_query(int fd,struct nmb_name *name,
-                                     struct in_addr to_ip, int *num_names);
-BOOL name_status_find(int type, struct in_addr to_ip, char *name);
-BOOL name_register(int fd, const char *name, int name_type,
-                  struct in_addr name_ip, int opcode,
-                  BOOL bcast, 
-                  struct in_addr to_ip, int *count);
-struct in_addr *name_query(int fd,const char *name,int name_type, 
-                          BOOL bcast,BOOL recurse,
-                          struct in_addr to_ip, int *count);
-FILE *startlmhosts(char *fname);
-BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr);
-void endlmhosts(FILE *fp);
-BOOL name_register_wins(const char *name, int name_type);
-BOOL name_resolve_bcast(const char *name, int name_type,
-                       struct in_addr **return_ip_list, int *return_count);
-BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type);
-BOOL resolve_srv_name(const char* srv_name, fstring dest_host,
-                                struct in_addr *ip);
-BOOL find_master_ip(char *group, struct in_addr *master_ip);
-BOOL lookup_pdc_name(const char *srcname, const char *domain, struct in_addr *pdc_ip, char *ret_name);
-BOOL get_dc_list(BOOL pdc_only, char *group, struct in_addr **ip_list, int *count);
-
-/*The following definitions come from  libsmb/nmblib.c  */
-
-void debug_nmb_packet(struct packet_struct *p);
-char *nmb_namestr(struct nmb_name *n);
-struct packet_struct *copy_packet(struct packet_struct *packet);
-void free_packet(struct packet_struct *packet);
-struct packet_struct *parse_packet(char *buf,int length,
-                                  enum packet_type packet_type);
-struct packet_struct *read_packet(int fd,enum packet_type packet_type);
-void make_nmb_name( struct nmb_name *n, const char *name, int type);
-BOOL nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2);
-int build_packet(char *buf, struct packet_struct *p);
-BOOL send_packet(struct packet_struct *p);
-struct packet_struct *receive_packet(int fd,enum packet_type type,int t);
-struct packet_struct *receive_nmb_packet(int fd, int t, int trn_id);
-struct packet_struct *receive_dgram_packet(int fd, int t, char *mailslot_name);
-BOOL match_mailslot_name(struct packet_struct *p, char *mailslot_name);
-void sort_query_replies(char *data, int n, struct in_addr ip);
-char *dns_to_netbios_name(char *dns_name);
-int name_mangle( char *In, char *Out, char name_type );
-int name_extract(char *buf,int ofs,char *name);
-int name_len(char *s1);
+void generate_wellknown_sids(void);
+BOOL map_domain_sid_to_name(DOM_SID *sid, char *nt_domain);
+BOOL lookup_known_rid(DOM_SID *sid, uint32 rid, char *name, enum SID_NAME_USE *psid_name_use);
+BOOL map_domain_name_to_sid(DOM_SID *sid, char *nt_domain);
+void split_domain_name(const char *fullname, char *domain, char *name);
+char *sid_to_string(fstring sidstr_out, DOM_SID *sid);
+BOOL string_to_sid(DOM_SID *sidout, char *sidstr);
+BOOL sid_append_rid(DOM_SID *sid, uint32 rid);
+BOOL sid_split_rid(DOM_SID *sid, uint32 *rid);
+void sid_copy(DOM_SID *dst, const DOM_SID *src);
+DOM_SID *sid_dup(DOM_SID *src);
+BOOL sid_linearize(char *outbuf, size_t len, DOM_SID *sid);
+int sid_compare(const DOM_SID *sid1, const DOM_SID *sid2);
+BOOL sid_equal(const DOM_SID *sid1, const DOM_SID *sid2);
+size_t sid_size(DOM_SID *sid);
 
-/*The following definitions come from  libsmb/nterr.c  */
+/*The following definitions come from  lib/util_sock.c  */
 
-BOOL get_safe_nt_error_msg(uint32 nt_code,char *msg, size_t len);
-char *get_nt_error_msg(uint32 nt_code);
+BOOL is_a_socket(int fd);
+void set_socket_options(int fd, char *options);
+ssize_t read_udp_socket(int fd,char *buf,size_t len);
+ssize_t read_with_timeout(int fd,char *buf,size_t mincnt,size_t maxcnt,unsigned int time_out);
+BOOL send_keepalive(int client);
+ssize_t read_data(int fd,char *buffer,size_t N);
+ssize_t write_data(int fd,char *buffer,size_t N);
+ssize_t write_socket_data(int fd,char *buffer,size_t N);
+ssize_t write_socket(int fd,char *buf,size_t len);
+ssize_t read_smb_length(int fd,char *inbuf,unsigned int timeout);
+BOOL receive_smb(int fd,char *buffer, unsigned int timeout);
+BOOL client_receive_smb(int fd,char *buffer, unsigned int timeout);
+BOOL send_null_session_msg(int fd);
+BOOL send_smb(int fd,char *buffer);
+BOOL send_one_packet(char *buf,int len,struct in_addr ip,int port,int type);
+int open_socket_in(int type, int port, int dlevel,uint32 socket_addr, BOOL rebind);
+int open_socket_out(int type, struct in_addr *addr, int port ,int timeout);
+void reset_globals_after_fork(void);
+void client_setfd(int fd);
+char *client_name(void);
+char *client_addr(void);
+char *get_socket_name(int fd);
+char *get_socket_addr(int fd);
+int open_pipe_sock(char *path);
+int create_pipe_socket(char *dir, int dir_perms,
+                               char *path, int path_perms);
 
-/*The following definitions come from  libsmb/passchange.c  */
+/*The following definitions come from  lib/util_str.c  */
 
-BOOL remote_password_change(const char *remote_machine, const char *user_name, 
-                           const char *old_passwd, const char *new_passwd,
-                           char *err_str, size_t err_str_len);
+void set_first_token(char *ptr);
+BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize);
+char **toktocliplist(int *ctok, char *sep);
+int StrCaseCmp(const char *s, const char *t);
+int StrnCaseCmp(const char *s, const char *t, size_t n);
+BOOL strequal(const char *s1, const char *s2);
+BOOL strnequal(const char *s1,const char *s2,size_t n);
+BOOL strcsequal(const char *s1,const char *s2);
+int strwicmp(char *psz1, char *psz2);
+void strlower(char *s);
+void strupper(char *s);
+void strnorm(char *s);
+BOOL strisnormal(char *s);
+void string_replace(char *s,char oldc,char newc);
+char *skip_string(char *buf,size_t n);
+size_t str_charnum(const char *s);
+BOOL trim_string(char *s,const char *front,const char *back);
+BOOL strhasupper(const char *s);
+BOOL strhaslower(const char *s);
+size_t count_chars(const char *s,char c);
+BOOL str_is_all(const char *s,char c);
+char *safe_strcpy(char *dest,const char *src, size_t maxlength);
+char *safe_strcat(char *dest, const char *src, size_t maxlength);
+char *alpha_strcpy(char *dest, const char *src, size_t maxlength);
+char *StrnCpy(char *dest,const char *src,size_t n);
+char *strncpyn(char *dest, const char *src,size_t n, char c);
+size_t strhex_to_str(char *p, size_t len, const char *strhex);
+BOOL in_list(char *s,char *list,BOOL casesensitive);
+void string_free(char **s);
+BOOL string_set(char **dest,const char *src);
+void string_sub(char *s,const char *pattern,const char *insert, size_t len);
+void fstring_sub(char *s,const char *pattern,const char *insert);
+void pstring_sub(char *s,const char *pattern,const char *insert);
+void all_string_sub(char *s,const char *pattern,const char *insert, size_t len);
+void split_at_last_component(char *path, char *front, char sep, char *back);
+char *octal_string(int i);
+char *string_truncate(char *s, int length);
+void parse_domain_user(char *domuser, fstring domain, fstring user);
 
-/*The following definitions come from  libsmb/pwd_cache.c  */
+/*The following definitions come from  lib/util_unistr.c  */
 
-void pwd_init(struct pwd_info *pwd);
-BOOL pwd_is_nullpwd(const struct pwd_info *pwd);
-BOOL pwd_compare(struct pwd_info *pwd1, struct pwd_info *pwd2);
-void pwd_read(struct pwd_info *pwd, char *passwd_report, BOOL do_encrypt);
-void pwd_set_nullpwd(struct pwd_info *pwd);
-void pwd_set_cleartext(struct pwd_info *pwd, char *clr);
-void pwd_get_cleartext(struct pwd_info *pwd, char *clr);
-void pwd_set_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]);
-void pwd_get_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]);
-void pwd_make_lm_nt_16(struct pwd_info *pwd, char *clr);
-void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8]);
-void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], uchar nt_owf[24]);
+size_t dos_PutUniCode(char *dst,const char *src, ssize_t len, BOOL null_terminate);
+void unistr_to_dos(char *dest, const char *src, size_t len);
+char *skip_unibuf(char *src, size_t len);
+char *dos_unistrn2(uint16 *src, int len);
+char *dos_unistr2(uint16 *src);
+char *dos_unistr2_to_str(UNISTR2 *str);
+void ascii_to_unistr(uint16 *dest, const char *src, int maxlen);
+void unistr_to_ascii(char *dest, const uint16 *src, int len);
+void unistr2_to_ascii(char *dest, const UNISTR2 *str, size_t maxlen);
+uint32 buffer2_to_uint32(BUFFER2 *str);
+char *dos_buffer2_to_str(BUFFER2 *str);
+char *dos_buffer2_to_multistr(BUFFER2 *str);
+size_t dos_struni2(char *dst, const char *src, size_t max_len);
+char *dos_unistr(char *buf);
+int unistrcpy(char *dst, char *src);
+void default_unicode_map(smb_ucs2_t **pp_cp_to_ucs2, uint16 **pp_ucs2_to_cp);
+BOOL load_unicode_map(const char *codepage, smb_ucs2_t **pp_cp_to_ucs2, uint16 **pp_ucs2_to_cp);
+BOOL load_dos_unicode_map(int codepage);
+BOOL load_unix_unicode_map(const char *unix_char_set);
+smb_ucs2_t *multibyte_to_unicode(smb_ucs2_t *dst, const char *src,
+                                 size_t dst_len, smb_ucs2_t *cp_to_ucs2);
+char *unicode_to_unix(char *dst, const smb_ucs2_t *src, size_t dst_len);
+smb_ucs2_t *unix_to_unicode(smb_ucs2_t *dst, const char *src, size_t dst_len);
+char *unicode_to_dos(char *dst, const smb_ucs2_t *src, size_t dst_len);
+size_t unicode_to_dos_char(char *dst, const smb_ucs2_t src);
+smb_ucs2_t *dos_to_unicode(smb_ucs2_t *dst, const char *src, size_t dst_len);
+size_t strlen_w(const smb_ucs2_t *src);
+smb_ucs2_t *safe_strcpy_w(smb_ucs2_t *dest,const smb_ucs2_t *src, size_t maxlength);
+smb_ucs2_t *safe_strcat_w(smb_ucs2_t *dest, const smb_ucs2_t *src, size_t maxlength);
+int strcmp_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2);
+int strncmp_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2, size_t len);
+smb_ucs2_t *strstr_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2);
+smb_ucs2_t *strchr_w(const smb_ucs2_t *s, smb_ucs2_t c);
+smb_ucs2_t *strrchr_w(const smb_ucs2_t *s, smb_ucs2_t c);
+smb_ucs2_t *strtok_w(smb_ucs2_t *s1, const smb_ucs2_t *s2);
+smb_ucs2_t *strdup_w(const smb_ucs2_t *s);
+int isupper_w( smb_ucs2_t val);
+int islower_w( smb_ucs2_t val);
+int isdigit_w( smb_ucs2_t val);
+int isxdigit_w( smb_ucs2_t val);
+int isspace_w( smb_ucs2_t val);
+smb_ucs2_t toupper_w( smb_ucs2_t val );
+smb_ucs2_t tolower_w( smb_ucs2_t val );
+void set_first_token_w(smb_ucs2_t *ptr);
+BOOL next_token_w(smb_ucs2_t **ptr, smb_ucs2_t *buff, smb_ucs2_t *sep, size_t bufsize);
+smb_ucs2_t **toktocliplist_w(int *ctok, smb_ucs2_t *sep);
+int StrCaseCmp_w(const smb_ucs2_t *s, const smb_ucs2_t *t);
+int StrnCaseCmp_w(const smb_ucs2_t *s, const smb_ucs2_t *t, size_t n);
+BOOL strequal_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2);
+BOOL strnequal_w(const smb_ucs2_t *s1,const smb_ucs2_t *s2,size_t n);
+BOOL strcsequal_w(const smb_ucs2_t *s1,const smb_ucs2_t *s2);
+void strlower_w(smb_ucs2_t *s);
+void strupper_w(smb_ucs2_t *s);
+void strnorm_w(smb_ucs2_t *s);
+BOOL strisnormal_w(smb_ucs2_t *s);
+void string_replace_w(smb_ucs2_t *s, smb_ucs2_t oldc, smb_ucs2_t newc);
+smb_ucs2_t *skip_string_w(smb_ucs2_t *buf,size_t n);
+size_t str_charnum_w(const smb_ucs2_t *s);
+BOOL trim_string_w(smb_ucs2_t *s,const smb_ucs2_t *front,const smb_ucs2_t *back);
+BOOL strhasupper_w(const smb_ucs2_t *s);
+BOOL strhaslower_w(const smb_ucs2_t *s);
+size_t count_chars_w(const smb_ucs2_t *s,smb_ucs2_t c);
+BOOL str_is_all_w(const smb_ucs2_t *s,smb_ucs2_t c);
+smb_ucs2_t *alpha_strcpy_w(smb_ucs2_t *dest, const smb_ucs2_t *src, size_t maxlength);
+smb_ucs2_t *StrnCpy_w(smb_ucs2_t *dest,const smb_ucs2_t *src,size_t n);
+smb_ucs2_t *strncpyn_w(smb_ucs2_t *dest, const smb_ucs2_t *src,size_t n, smb_ucs2_t c);
+size_t strhex_to_str_w(char *p, size_t len, const smb_ucs2_t *strhex);
+BOOL in_list_w(smb_ucs2_t *s,smb_ucs2_t *list,BOOL casesensitive);
+BOOL string_init_w(smb_ucs2_t **dest,const smb_ucs2_t *src);
+void string_free_w(smb_ucs2_t **s);
+BOOL string_set_w(smb_ucs2_t **dest,const smb_ucs2_t *src);
+void string_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,const smb_ucs2_t *insert, size_t len);
+void fstring_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,const smb_ucs2_t *insert);
+void pstring_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,smb_ucs2_t *insert);
+void all_string_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,const smb_ucs2_t *insert, size_t len);
+void split_at_last_component_w(smb_ucs2_t *path, smb_ucs2_t *front, smb_ucs2_t sep, smb_ucs2_t *back);
+smb_ucs2_t *octal_string_w(int i);
+smb_ucs2_t *string_truncate_w(smb_ucs2_t *s, size_t length);
+smb_ucs2_t doscp2ucs2(int w);
+int ucs2doscp(smb_ucs2_t w);
 
-/*The following definitions come from  lib/smbrun.c  */
+/*The following definitions come from  lib/wins_srv.c  */
 
-int smbrun(char *cmd,char *outfile,BOOL shared);
+BOOL wins_srv_load_list( char *src );
+struct in_addr wins_srv_ip( void );
+void wins_srv_died( struct in_addr boothill_ip );
+unsigned long wins_srv_count( void );
 
-/*The following definitions come from  libsmb/smbdes.c  */
+/*The following definitions come from  libsmb/cli_lsarpc.c  */
 
-void E_P16(unsigned char *p14,unsigned char *p16);
-void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24);
-void D_P16(unsigned char *p14, unsigned char *in, unsigned char *out);
-void E_old_pw_hash( unsigned char *p14, unsigned char *in, unsigned char *out);
-void cred_hash1(unsigned char *out,unsigned char *in,unsigned char *key);
-void cred_hash2(unsigned char *out,unsigned char *in,unsigned char *key);
-void cred_hash3(unsigned char *out,unsigned char *in,unsigned char *key, int forw);
-void SamOEMhash( unsigned char *data, unsigned char *key, int val);
+struct cli_state *cli_lsa_initialise(struct cli_state *cli, char *system_name,
+                                    struct ntuser_creds *creds);
+void cli_lsa_shutdown(struct cli_state *cli);
+uint32 cli_lsa_open_policy(struct cli_state *cli, BOOL sec_qos, 
+                          uint32 des_access, POLICY_HND *pol);
+uint32 cli_lsa_close(struct cli_state *cli, POLICY_HND *pol);
+uint32 cli_lsa_lookup_sids(struct cli_state *cli, POLICY_HND *pol,
+                          int num_sids, DOM_SID *sids, char ***names, 
+                          uint32 **types, int *num_names);
+uint32 cli_lsa_lookup_names(struct cli_state *cli, POLICY_HND *pol,
+                           int num_names, char **names, DOM_SID **sids,
+                           uint32 **types, int *num_sids);
+uint32 cli_lsa_query_info_policy(struct cli_state *cli, POLICY_HND *pol, 
+                                uint16 info_class, fstring domain_name, 
+                                DOM_SID * domain_sid);
+uint32 cli_lsa_enum_trust_dom(struct cli_state *cli, POLICY_HND *pol, 
+                             uint32 *enum_ctx, uint32 *num_domains,
+                             char ***domain_names, DOM_SID **domain_sids);
 
-/*The following definitions come from  libsmb/smbencrypt.c  */
+/*The following definitions come from  libsmb/cli_samr.c  */
 
-void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24);
-void E_md4hash(uchar *passwd, uchar *p16);
-void nt_lm_owf_gen(char *pwd, uchar nt_p16[16], uchar p16[16]);
-void SMBOWFencrypt(uchar passwd[16], uchar *c8, uchar p24[24]);
-void NTLMSSPOWFencrypt(uchar passwd[8], uchar *ntlmchalresp, uchar p24[24]);
-void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24);
-BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[16], BOOL unicode);
-BOOL decode_pw_buffer(char buffer[516], char *new_pwrd,
-                     int new_pwrd_size, uint32 *new_pw_len);
+struct cli_state *cli_samr_initialise(struct cli_state *cli, char *system_name,
+                                     struct ntuser_creds *creds);
+void cli_samr_shutdown(struct cli_state *cli);
+uint32 cli_samr_connect(struct cli_state *cli, char *srv_name,
+                       uint32 access_mask, POLICY_HND *connect_pol);
+uint32 cli_samr_close(struct cli_state *cli, POLICY_HND *connect_pol);
+uint32 cli_samr_open_domain(struct cli_state *cli, POLICY_HND *connect_pol,
+                           uint32 access_mask, DOM_SID *domain_sid,
+                           POLICY_HND *domain_pol);
+uint32 cli_samr_open_user(struct cli_state *cli, POLICY_HND *domain_pol,
+                         uint32 access_mask, uint32 user_rid,
+                         POLICY_HND *user_pol);
+uint32 cli_samr_open_group(struct cli_state *cli, POLICY_HND *domain_pol,
+                         uint32 access_mask, uint32 group_rid,
+                         POLICY_HND *group_pol);
+uint32 cli_samr_query_userinfo(struct cli_state *cli, POLICY_HND *user_pol, 
+                              uint16 switch_value, SAM_USERINFO_CTR *ctr);
+uint32 cli_samr_query_groupinfo(struct cli_state *cli, POLICY_HND *group_pol,
+                               uint32 info_level, GROUP_INFO_CTR *ctr);
+uint32 cli_samr_query_usergroups(struct cli_state *cli, POLICY_HND *user_pol,
+                                uint32 *num_groups, DOM_GID **gid);
+uint32 cli_samr_query_groupmem(struct cli_state *cli, POLICY_HND *group_pol,
+                              uint32 *num_mem, uint32 **rid, uint32 **attr);
 
-/*The following definitions come from  libsmb/smberr.c  */
+/*The following definitions come from  libsmb/cli_spoolss.c  */
 
-char *smb_errstr(char *inbuf);
+struct cli_state *cli_spoolss_initialise(struct cli_state *cli, 
+                                        char *system_name,
+                                        struct ntuser_creds *creds);
+void cli_spoolss_shutdown(struct cli_state *cli);
+uint32 cli_spoolss_open_printer_ex(struct cli_state *cli, char *printername,
+                                  char *datatype, uint32 access_required,
+                                  char *station, char *username,
+                                  POLICY_HND *pol);
+uint32 cli_spoolss_closeprinter(struct cli_state *cli, POLICY_HND *pol);
+uint32 cli_spoolss_enum_printers(struct cli_state *cli, uint32 flags,
+                                uint32 level, int *returned, 
+                                PRINTER_INFO_CTR *ctr);
+uint32 cli_spoolss_enum_ports(struct cli_state *cli, uint32 level, 
+                             int *returned, PORT_INFO_CTR *ctr);
+uint32 cli_spoolss_getprinter(struct cli_state *cli, POLICY_HND *pol,
+                             uint32 level, PRINTER_INFO_CTR *ctr);
 
-/*The following definitions come from  libsmb/unexpected.c  */
+/*The following definitions come from  libsmb/cliconnect.c  */
 
-void unexpected_packet(struct packet_struct *p);
-void clear_unexpected(time_t t);
-struct packet_struct *receive_unexpected(enum packet_type packet_type, int id, 
-                                        char *mailslot_name);
+BOOL cli_session_setup(struct cli_state *cli, 
+                      char *user, 
+                      char *pass, int passlen,
+                      char *ntpass, int ntpasslen,
+                      char *workgroup);
+BOOL cli_ulogoff(struct cli_state *cli);
+BOOL cli_send_tconX(struct cli_state *cli, 
+                   char *share, char *dev, char *pass, int passlen);
+BOOL cli_tdis(struct cli_state *cli);
+void cli_negprot_send(struct cli_state *cli);
+BOOL cli_negprot(struct cli_state *cli);
+BOOL cli_session_request(struct cli_state *cli,
+                        struct nmb_name *calling, struct nmb_name *called);
+BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip);
+BOOL cli_reestablish_connection(struct cli_state *cli);
+BOOL cli_establish_connection(struct cli_state *cli, 
+                               char *dest_host, struct in_addr *dest_ip,
+                               struct nmb_name *calling, struct nmb_name *called,
+                               char *service, char *service_type,
+                               BOOL do_shutdown, BOOL do_tcon);
+BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost, char *desthost,
+                                     struct in_addr *pdest_ip);
 
-/*The following definitions come from  lib/snprintf.c  */
+/*The following definitions come from  libsmb/clidgram.c  */
 
+int cli_send_mailslot(int dgram_sock, BOOL unique, char *mailslot, 
+                     char *buf, int len,
+                     const char *srcname, int src_type, 
+                     const char *dstname, int dest_type,
+                     struct in_addr dest_ip, struct in_addr src_ip,
+                     int dest_port, int src_port);
+int cli_get_response(int dgram_sock, BOOL unique, char *mailslot, char *buf, int bufsiz);
+int cli_get_backup_list(const char *myname, const char *send_to_name);
+int cli_get_backup_server(char *my_name, char *target, char *servername, int namesize);
 
-/*The following definitions come from  lib/substitute.c  */
+/*The following definitions come from  libsmb/clientgen.c  */
 
-void standard_sub_basic(char *str);
-void standard_sub_advanced(int snum, char *user, char *connectpath, gid_t gid, char *str);
-void standard_sub_conn(connection_struct *conn, char *str);
-void standard_sub_snum(int snum, char *str);
-void standard_sub_vuser(char *str, user_struct *vuser);
-void standard_sub_vsnum(char *str, user_struct *vuser, int snum);
+int cli_set_port(struct cli_state *cli, int port);
+BOOL cli_receive_smb(struct cli_state *cli);
+BOOL cli_send_smb(struct cli_state *cli);
+void cli_setup_packet(struct cli_state *cli);
+void cli_setup_bcc(struct cli_state *cli, void *p);
+void cli_init_creds(struct cli_state *cli, const struct ntuser_creds *usr);
+struct cli_state *cli_initialise(struct cli_state *cli);
+void cli_shutdown(struct cli_state *cli);
+void cli_sockopt(struct cli_state *cli, char *options);
+uint16 cli_setpid(struct cli_state *cli, uint16 pid);
 
-/*The following definitions come from  lib/sysacls.c  */
+/*The following definitions come from  libsmb/clierror.c  */
 
-int sys_acl_get_entry( SMB_ACL_T the_acl, int entry_id, SMB_ACL_ENTRY_T *entry_p);
-int sys_acl_get_tag_type( SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p);
-int sys_acl_get_permset( SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p);
-void *sys_acl_get_qualifier( SMB_ACL_ENTRY_T entry_d);
-SMB_ACL_T sys_acl_get_file( const char *path_p, SMB_ACL_TYPE_T type);
-SMB_ACL_T sys_acl_get_fd(int fd);
-int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset);
-int sys_acl_add_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm);
-int sys_acl_get_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm);
-char *sys_acl_to_text( SMB_ACL_T the_acl, ssize_t *plen);
-SMB_ACL_T sys_acl_init( int count);
-int sys_acl_create_entry( SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry);
-int sys_acl_set_tag_type( SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype);
-int sys_acl_set_qualifier( SMB_ACL_ENTRY_T entry, void *qual);
-int sys_acl_set_permset( SMB_ACL_ENTRY_T entry, SMB_ACL_PERMSET_T permset);
-int sys_acl_valid( SMB_ACL_T theacl );
-int sys_acl_set_file( char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl);
-int sys_acl_set_fd( int fd, SMB_ACL_T theacl);
-int sys_acl_free_text(char *text);
-int sys_acl_free_acl(SMB_ACL_T the_acl) ;
-int sys_acl_get_entry(SMB_ACL_T acl_d, int entry_id, SMB_ACL_ENTRY_T *entry_p);
-int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *type_p);
-int sys_acl_get_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p);
-void *sys_acl_get_qualifier(SMB_ACL_ENTRY_T entry_d);
-SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type);
-SMB_ACL_T sys_acl_get_fd(int fd);
-int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d);
-int sys_acl_add_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm);
-int sys_acl_get_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm);
-char *sys_acl_to_text(SMB_ACL_T acl_d, ssize_t *len_p);
-SMB_ACL_T sys_acl_init(int count);
-int sys_acl_create_entry(SMB_ACL_T *acl_p, SMB_ACL_ENTRY_T *entry_p);
-int sys_acl_set_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T tag_type);
-int sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry_d, void *qual_p);
-int sys_acl_set_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T permset_d);
-int sys_acl_valid(SMB_ACL_T acl_d);
-int sys_acl_set_file(char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
-int sys_acl_set_fd(int fd, SMB_ACL_T acl_d);
-int sys_acl_free_text(char *text);
-int sys_acl_free_acl(SMB_ACL_T acl_d) ;
-int sys_acl_get_entry(SMB_ACL_T acl_d, int entry_id, SMB_ACL_ENTRY_T *entry_p);
-int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *type_p);
-int sys_acl_get_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p);
-void *sys_acl_get_qualifier(SMB_ACL_ENTRY_T entry_d);
-SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type);
-SMB_ACL_T sys_acl_get_fd(int fd);
-int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d);
-int sys_acl_add_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm);
-int sys_acl_get_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm);
-char *sys_acl_to_text(SMB_ACL_T acl_d, ssize_t *len_p);
-SMB_ACL_T sys_acl_init(int count);
-int sys_acl_create_entry(SMB_ACL_T *acl_p, SMB_ACL_ENTRY_T *entry_p);
-int sys_acl_set_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T tag_type);
-int sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry_d, void *qual_p);
-int sys_acl_set_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T permset_d);
-int sys_acl_valid(SMB_ACL_T acl_d);
-int sys_acl_set_file(char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
-int sys_acl_set_fd(int fd, SMB_ACL_T acl_d);
-int sys_acl_free_text(char *text);
-int sys_acl_free_acl(SMB_ACL_T acl_d) ;
-int sys_acl_get_entry( SMB_ACL_T the_acl, int entry_id, SMB_ACL_ENTRY_T *entry_p);
-int sys_acl_get_tag_type( SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p);
-int sys_acl_get_permset( SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p);
-void *sys_acl_get_qualifier( SMB_ACL_ENTRY_T entry_d);
-SMB_ACL_T sys_acl_get_file( const char *path_p, SMB_ACL_TYPE_T type);
-SMB_ACL_T sys_acl_get_fd(int fd);
-int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset);
-int sys_acl_add_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm);
-int sys_acl_get_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm);
-char *sys_acl_to_text( SMB_ACL_T the_acl, ssize_t *plen);
-int sys_acl_free_text(char *text);
-SMB_ACL_T sys_acl_init( int count);
-int sys_acl_create_entry( SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry);
-int sys_acl_set_tag_type( SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype);
-int sys_acl_set_qualifier( SMB_ACL_ENTRY_T entry, void *qual);
-int sys_acl_set_permset( SMB_ACL_ENTRY_T entry, SMB_ACL_PERMSET_T permset);
-int sys_acl_valid( SMB_ACL_T theacl );
-int sys_acl_set_file( char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl);
-int sys_acl_set_fd( int fd, SMB_ACL_T theacl);
-int sys_acl_free_acl(SMB_ACL_T the_acl) ;
+char *cli_errstr(struct cli_state *cli);
+int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_error);
 
-/*The following definitions come from  lib/system.c  */
+/*The following definitions come from  libsmb/clifile.c  */
 
-int sys_usleep(long usecs);
-int sys_stat(const char *fname,SMB_STRUCT_STAT *sbuf);
-int sys_fstat(int fd,SMB_STRUCT_STAT *sbuf);
-int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf);
-int sys_ftruncate(int fd, SMB_OFF_T offset);
-SMB_OFF_T sys_lseek(int fd, SMB_OFF_T offset, int whence);
-int sys_fseek(FILE *fp, SMB_OFF_T offset, int whence);
-SMB_OFF_T sys_ftell(FILE *fp);
-int sys_creat(const char *path, mode_t mode);
-int sys_open(const char *path, int oflag, mode_t mode);
-FILE *sys_fopen(const char *path, const char *type);
-SMB_STRUCT_DIRENT *sys_readdir(DIR *dirp);
-int sys_waitpid(pid_t pid,int *status,int options);
-char *sys_getwd(char *s);
-int sys_chown(const char *fname,uid_t uid,gid_t gid);
-int sys_chroot(const char *dname);
-struct hostent *sys_gethostbyname(const char *name);
-void oplock_set_capability(BOOL this_process, BOOL inherit);
-long sys_random(void);
-void sys_srandom(unsigned int seed);
-int groups_max(void);
-int sys_getgroups(int setlen, gid_t *gidset);
-int sys_setgroups(int setlen, gid_t *gidset);
-void sys_setpwent(void);
-struct passwd *sys_getpwent(void);
-void sys_endpwent(void);
-struct passwd *sys_getpwnam(const char *name);
-struct passwd *sys_getpwuid(uid_t uid);
-int wsys_stat(const smb_ucs2_t *wfname,SMB_STRUCT_STAT *sbuf);
-int wsys_lstat(const smb_ucs2_t *wfname,SMB_STRUCT_STAT *sbuf);
-int wsys_creat(const smb_ucs2_t *wfname, mode_t mode);
-int wsys_open(const smb_ucs2_t *wfname, int oflag, mode_t mode);
-FILE *wsys_fopen(const smb_ucs2_t *wfname, const char *type);
-DIR *wsys_opendir(const smb_ucs2_t *wfname);
-smb_ucs2_t *wsys_getwd(smb_ucs2_t *s);
-int wsys_chown(const smb_ucs2_t *wfname, uid_t uid, gid_t gid);
-int wsys_chroot(const smb_ucs2_t *wfname);
-pid_t sys_fork(void);
-pid_t sys_getpid(void);
-int sys_popen(const char *command);
-int sys_pclose(int fd);
+BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst);
+BOOL cli_unlink(struct cli_state *cli, char *fname);
+BOOL cli_mkdir(struct cli_state *cli, char *dname);
+BOOL cli_rmdir(struct cli_state *cli, char *dname);
+int cli_nt_create(struct cli_state *cli, char *fname, uint32 DesiredAccess);
+int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode);
+BOOL cli_close(struct cli_state *cli, int fnum);
+BOOL cli_lock(struct cli_state *cli, int fnum, 
+             uint32 offset, uint32 len, int timeout, enum brl_type lock_type);
+BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len);
+BOOL cli_lock64(struct cli_state *cli, int fnum, 
+               SMB_BIG_UINT offset, SMB_BIG_UINT len, int timeout, enum brl_type lock_type);
+BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_UINT len);
+BOOL cli_getattrE(struct cli_state *cli, int fd, 
+                 uint16 *attr, size_t *size, 
+                 time_t *c_time, time_t *a_time, time_t *m_time);
+BOOL cli_getatr(struct cli_state *cli, char *fname, 
+               uint16 *attr, size_t *size, time_t *t);
+BOOL cli_setatr(struct cli_state *cli, char *fname, uint16 attr, time_t t);
+BOOL cli_chkpath(struct cli_state *cli, char *path);
+BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
 
-/*The following definitions come from  lib/talloc.c  */
+/*The following definitions come from  libsmb/clilist.c  */
 
-TALLOC_CTX *talloc_init(void);
-void *talloc(TALLOC_CTX *t, size_t size);
-void talloc_destroy_pool(TALLOC_CTX *t);
-void talloc_destroy(TALLOC_CTX *t);
-size_t talloc_pool_size(TALLOC_CTX *t);
-void *talloc_zero(TALLOC_CTX *t, size_t size);
-void *talloc_memdup(TALLOC_CTX *t, void *p, size_t size);
+int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute, 
+                void (*fn)(file_info *, const char *, void *), void *state);
+int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, 
+                void (*fn)(file_info *, const char *, void *), void *state);
+int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, 
+            void (*fn)(file_info *, const char *, void *), void *state);
 
-/*The following definitions come from  lib/time.c  */
+/*The following definitions come from  libsmb/climessage.c  */
 
-void GetTimeOfDay(struct timeval *tval);
-void TimeInit(void);
-int TimeDiff(time_t t);
-struct tm *LocalTime(time_t *t);
-time_t nt_time_to_unix(NTTIME *nt);
-time_t interpret_long_date(char *p);
-void unix_to_nt_time(NTTIME *nt, time_t t);
-void put_long_date(char *p,time_t t);
-BOOL null_mtime(time_t mtime);
-void put_dos_date(char *buf,int offset,time_t unixdate);
-void put_dos_date2(char *buf,int offset,time_t unixdate);
-void put_dos_date3(char *buf,int offset,time_t unixdate);
-time_t make_unix_date(void *date_ptr);
-time_t make_unix_date2(void *date_ptr);
-time_t make_unix_date3(void *date_ptr);
-char *http_timestring(time_t t);
-char *timestring(BOOL hires);
-time_t get_create_time(SMB_STRUCT_STAT *st,BOOL fake_dirs);
+BOOL cli_message_start(struct cli_state *cli, char *host, char *username, 
+                             int *grp);
+BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp);
+BOOL cli_message_end(struct cli_state *cli, int grp);
 
-/*The following definitions come from  lib/ufc.c  */
+/*The following definitions come from  libsmb/cliprint.c  */
 
-char *ufc_crypt(char *key,char *salt);
+int cli_print_queue(struct cli_state *cli, 
+                   void (*fn)(struct print_job_info *));
+int cli_printjob_del(struct cli_state *cli, int job);
 
-/*The following definitions come from  lib/username.c  */
+/*The following definitions come from  libsmb/clirap.c  */
 
-char *get_user_home_dir(char *user);
-BOOL map_username(char *user);
-struct passwd *Get_Pwnam(char *user,BOOL allow_change);
-BOOL user_in_group_list(char *user,char *gname);
-BOOL user_in_list(char *user,char *list);
-struct passwd *smb_getpwnam(char *user, BOOL allow_change);
+BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, 
+                  uint16 *setup, uint32 setup_count, uint32 max_setup_count,
+                  char *params, uint32 param_count, uint32 max_param_count,
+                  char *data, uint32 data_count, uint32 max_data_count,
+                  char **rparam, uint32 *rparam_count,
+                  char **rdata, uint32 *rdata_count);
+BOOL cli_api(struct cli_state *cli,
+            char *param, int prcnt, int mprcnt,
+            char *data, int drcnt, int mdrcnt,
+            char **rparam, int *rprcnt,
+            char **rdata, int *rdrcnt);
+BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation);
+int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *, void *), void *state);
+BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
+                      void (*fn)(const char *, uint32, const char *, void *),
+                      void *state);
+BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password,
+                             const char *old_password);
+BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, 
+                  time_t *c_time, time_t *a_time, time_t *m_time, 
+                  size_t *size, uint16 *mode);
+BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, 
+                   time_t *c_time, time_t *a_time, time_t *m_time, 
+                   time_t *w_time, size_t *size, uint16 *mode,
+                   SMB_INO_T *ino);
+BOOL cli_qfileinfo(struct cli_state *cli, int fnum, 
+                  uint16 *mode, size_t *size,
+                  time_t *c_time, time_t *a_time, time_t *m_time, 
+                  time_t *w_time, SMB_INO_T *ino);
 
-/*The following definitions come from  lib/util_array.c  */
+/*The following definitions come from  libsmb/clireadwrite.c  */
 
-void free_void_array(uint32 num_entries, void **entries,
-               void(free_item)(void*));
-void* add_copy_to_array(uint32 *len, void ***array, const void *item,
-       void*(item_dup)(const void*), BOOL alloc_anyway);
-void* add_item_to_array(uint32 *len, void ***array, void *item);
-void free_use_info_array(uint32 num_entries, struct use_info **entries);
-struct use_info* add_use_info_to_array(uint32 *len, struct use_info ***array,
-                               const struct use_info *name);
-void free_char_array(uint32 num_entries, char **entries);
-char* add_chars_to_array(uint32 *len, char ***array, const char *name);
-void free_uint32_array(uint32 num_entries, uint32 **entries);
-uint32* add_uint32s_to_array(uint32 *len, uint32 ***array, const uint32 *name);
-void free_sid_array(uint32 num_entries, DOM_SID **entries);
-DOM_SID* add_sid_to_array(uint32 *len, DOM_SID ***array, const DOM_SID *sid);
+size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size);
+ssize_t cli_write(struct cli_state *cli,
+                 int fnum, uint16 write_mode,
+                 char *buf, off_t offset, size_t size);
+ssize_t cli_smbwrite(struct cli_state *cli,
+                    int fnum, char *buf, off_t offset, size_t size1);
 
-/*The following definitions come from  lib/util.c  */
+/*The following definitions come from  libsmb/clisecdesc.c  */
 
-char *tmpdir(void);
-BOOL in_group(gid_t group, gid_t current_gid, int ngroups, gid_t *groups);
-char *Atoic(char *p, int *n, char *c);
-char *get_numlist(char *p, uint32 **num, int *count);
-BOOL file_exist(char *fname,SMB_STRUCT_STAT *sbuf);
-int file_rename(char *from, char *to);
-time_t file_modtime(char *fname);
-BOOL directory_exist(char *dname,SMB_STRUCT_STAT *st);
-SMB_OFF_T get_file_size(char *file_name);
-char *attrib_string(uint16 mode);
-void show_msg(char *buf);
-void smb_setlen(char *buf,int len);
-int set_message(char *buf,int num_words,int num_bytes,BOOL zero);
-void set_message_bcc(char *buf,int num_bytes);
-void set_message_end(void *outbuf,void *end_ptr);
-void dos_clean_name(char *s);
-void unix_clean_name(char *s);
-void make_dir_struct(char *buf,char *mask,char *fname,SMB_OFF_T size,int mode,time_t date);
-void close_low_fds(void);
-int set_blocking(int fd, BOOL set);
-SMB_OFF_T transfer_file(int infd,int outfd,SMB_OFF_T n,char *header,int headlen,int align);
-void msleep(int t);
-void become_daemon(void);
-BOOL yesno(char *p);
-void *Realloc(void *p,size_t size);
-void safe_free(void *p);
-BOOL get_myname(char *my_name);
-int interpret_protocol(char *str,int def);
-BOOL is_ipaddress(const char *str);
-uint32 interpret_addr(char *str);
-struct in_addr *interpret_addr2(char *str);
-BOOL zero_ip(struct in_addr ip);
-BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
-struct hostent *Get_Hostbyname(const char *name);
-BOOL process_exists(pid_t pid);
-char *uidtoname(uid_t uid);
-char *gidtoname(gid_t gid);
-uid_t nametouid(char *name);
-gid_t nametogid(char *name);
-void smb_panic(char *why);
-char *readdirname(DIR *p);
-BOOL is_in_path(char *name, name_compare_entry *namelist);
-void set_namearray(name_compare_entry **ppname_array, char *namelist);
-void free_namearray(name_compare_entry *name_array);
-BOOL fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
-BOOL is_myname(char *s);
-void set_remote_arch(enum remote_arch_types type);
-enum remote_arch_types get_remote_arch(void);
-void out_ascii(FILE *f, unsigned char *buf,int len);
-void out_data(FILE *f,char *buf1,int len, int per_line);
-void print_asc(int level, unsigned char *buf,int len);
-void dump_data(int level,char *buf1,int len);
-char *tab_depth(int depth);
-int str_checksum(const char *s);
-void zero_free(void *p, size_t size);
-int set_maxfiles(int requested_max);
-BOOL reg_split_key(char *full_keyname, uint32 *reg_type, char *key_name);
-char *smbd_mktemp(char *template);
-void *memdup(void *p, size_t size);
-char *myhostname(void);
-char *lock_path(char *name);
-char *parent_dirname(const char *path);
-BOOL ms_has_wild(char *s);
-BOOL mask_match(char *string, char *pattern, BOOL is_case_sensitive);
-int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6);
+SEC_DESC *cli_query_secdesc(struct cli_state *cli,int fd);
+BOOL cli_set_secdesc(struct cli_state *cli,int fd, SEC_DESC *sd);
 
-/*The following definitions come from  lib/util_file.c  */
+/*The following definitions come from  libsmb/clistr.c  */
 
-BOOL do_file_lock(int fd, int waitsecs, int type);
-BOOL file_lock(int fd, int type, int secs, int *plock_depth);
-BOOL file_unlock(int fd, int *plock_depth);
-void *startfilepwent(char *pfile, char *s_readbuf, int bufsize,
-                               int *file_lock_depth, BOOL update);
-void endfilepwent(void *vp, int *file_lock_depth);
-SMB_BIG_UINT getfilepwpos(void *vp);
-BOOL setfilepwpos(void *vp, SMB_BIG_UINT tok);
-int getfileline(void *vp, char *linebuf, int linebuf_size);
-char *fgets_slash(char *s2,int maxlen,FILE *f);
-char *file_pload(char *syscmd, size_t *size);
-char *file_load(char *fname, size_t *size);
-char **file_lines_load(char *fname, int *numlines, BOOL convert);
-char **file_lines_pload(char *syscmd, int *numlines, BOOL convert);
-void file_lines_free(char **lines);
-void file_lines_slashcont(char **lines);
+int clistr_push(struct cli_state *cli, void *dest, const char *src, int dest_len, int flags);
+int clistr_push_size(struct cli_state *cli, const void *dest, const char *src, int dest_len, int flags);
+int clistr_pull(struct cli_state *cli, char *dest, const void *src, int dest_len, int src_len, int flags);
+int clistr_pull_size(struct cli_state *cli, const void *src, int src_len);
+int clistr_align(struct cli_state *cli, int offset);
 
-/*The following definitions come from  lib/util_list.c  */
+/*The following definitions come from  libsmb/clitrans.c  */
 
-BOOL copy_policy_hnd (POLICY_HND *dest, const POLICY_HND *src);
-BOOL compare_rpc_hnd_node(const RPC_HND_NODE *x, 
-                         const RPC_HND_NODE *y);
-BOOL RpcHndList_set_connection(const POLICY_HND *hnd, 
-                              struct cli_connection *con);
-BOOL RpcHndList_del_connection(const POLICY_HND *hnd);
-struct cli_connection* RpcHndList_get_connection(const POLICY_HND *hnd);
+BOOL cli_send_trans(struct cli_state *cli, int trans, 
+                   char *pipe_name, 
+                   int fid, int flags,
+                   uint16 *setup, int lsetup, int msetup,
+                   char *param, int lparam, int mparam,
+                   char *data, int ldata, int mdata);
+BOOL cli_receive_trans(struct cli_state *cli,int trans,
+                              char **param, int *param_len,
+                              char **data, int *data_len);
+BOOL cli_send_nt_trans(struct cli_state *cli, 
+                      int function, 
+                      int flags,
+                      uint16 *setup, int lsetup, int msetup,
+                      char *param, int lparam, int mparam,
+                      char *data, int ldata, int mdata);
+BOOL cli_receive_nt_trans(struct cli_state *cli,
+                         char **param, int *param_len,
+                         char **data, int *data_len);
+
+/*The following definitions come from  libsmb/credentials.c  */
+
+char *credstr(uchar *cred);
+void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, char *pass, 
+                     uchar session_key[8]);
+void cred_create(uchar session_key[8], DOM_CHAL *stor_cred, UTIME timestamp, 
+                DOM_CHAL *cred);
+int cred_assert(DOM_CHAL *cred, uchar session_key[8], DOM_CHAL *stored_cred,
+               UTIME timestamp);
+BOOL clnt_deal_with_creds(uchar sess_key[8],
+                         DOM_CRED *sto_clnt_cred, DOM_CRED *rcv_srv_cred);
+BOOL deal_with_creds(uchar sess_key[8],
+                    DOM_CRED *sto_clnt_cred, 
+                    DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred);
+
+/*The following definitions come from  libsmb/namequery.c  */
 
-/*The following definitions come from  lib/util_seaccess.c  */
+struct node_status *name_status_query(int fd,struct nmb_name *name,
+                                     struct in_addr to_ip, int *num_names);
+BOOL name_status_find(int type, struct in_addr to_ip, char *name);
+BOOL name_register(int fd, const char *name, int name_type,
+                  struct in_addr name_ip, int opcode,
+                  BOOL bcast, 
+                  struct in_addr to_ip, int *count);
+struct in_addr *name_query(int fd,const char *name,int name_type, 
+                          BOOL bcast,BOOL recurse,
+                          struct in_addr to_ip, int *count);
+FILE *startlmhosts(char *fname);
+BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr);
+void endlmhosts(FILE *fp);
+BOOL name_register_wins(const char *name, int name_type);
+BOOL name_resolve_bcast(const char *name, int name_type,
+                       struct in_addr **return_ip_list, int *return_count);
+BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type);
+BOOL resolve_srv_name(const char* srv_name, fstring dest_host,
+                                struct in_addr *ip);
+BOOL find_master_ip(char *group, struct in_addr *master_ip);
+BOOL lookup_pdc_name(const char *srcname, const char *domain, struct in_addr *pdc_ip, char *ret_name);
+BOOL get_dc_list(BOOL pdc_only, char *group, struct in_addr **ip_list, int *count);
 
-void se_map_generic(uint32 *access_mask, struct generic_mapping *mapping);
-BOOL se_access_check(SEC_DESC *sd, struct current_user *user,
-                    uint32 acc_desired, uint32 *acc_granted, uint32 *status);
-SEC_DESC_BUF *se_create_child_secdesc(TALLOC_CTX *ctx, SEC_DESC *parent_ctr, 
-                                     BOOL child_container);
+/*The following definitions come from  libsmb/nmblib.c  */
 
-/*The following definitions come from  lib/util_sec.c  */
+void debug_nmb_packet(struct packet_struct *p);
+char *nmb_namestr(struct nmb_name *n);
+struct packet_struct *copy_packet(struct packet_struct *packet);
+void free_packet(struct packet_struct *packet);
+struct packet_struct *parse_packet(char *buf,int length,
+                                  enum packet_type packet_type);
+struct packet_struct *read_packet(int fd,enum packet_type packet_type);
+void make_nmb_name( struct nmb_name *n, const char *name, int type);
+BOOL nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2);
+int build_packet(char *buf, struct packet_struct *p);
+BOOL send_packet(struct packet_struct *p);
+struct packet_struct *receive_packet(int fd,enum packet_type type,int t);
+struct packet_struct *receive_nmb_packet(int fd, int t, int trn_id);
+struct packet_struct *receive_dgram_packet(int fd, int t, char *mailslot_name);
+BOOL match_mailslot_name(struct packet_struct *p, char *mailslot_name);
+void sort_query_replies(char *data, int n, struct in_addr ip);
+char *dns_to_netbios_name(char *dns_name);
+int name_mangle( char *In, char *Out, char name_type );
+int name_extract(char *buf,int ofs,char *name);
+int name_len(char *s1);
 
-void gain_root_privilege(void);
-void gain_root_group_privilege(void);
-void set_effective_uid(uid_t uid);
-void set_effective_gid(gid_t gid);
-void save_re_uid(void);
-void restore_re_uid(void);
-int set_re_uid(void);
-void become_user_permanently(uid_t uid, gid_t gid);
+/*The following definitions come from  libsmb/nterr.c  */
 
-/*The following definitions come from  lib/util_sid.c  */
+BOOL get_safe_nt_error_msg(uint32 nt_code,char *msg, size_t len);
+char *get_nt_error_msg(uint32 nt_code);
 
-void generate_wellknown_sids(void);
-BOOL map_domain_sid_to_name(DOM_SID *sid, char *nt_domain);
-BOOL lookup_known_rid(DOM_SID *sid, uint32 rid, char *name, enum SID_NAME_USE *psid_name_use);
-BOOL map_domain_name_to_sid(DOM_SID *sid, char *nt_domain);
-void split_domain_name(const char *fullname, char *domain, char *name);
-char *sid_to_string(fstring sidstr_out, DOM_SID *sid);
-BOOL string_to_sid(DOM_SID *sidout, char *sidstr);
-BOOL sid_append_rid(DOM_SID *sid, uint32 rid);
-BOOL sid_split_rid(DOM_SID *sid, uint32 *rid);
-void sid_copy(DOM_SID *dst, const DOM_SID *src);
-DOM_SID *sid_dup(DOM_SID *src);
-BOOL sid_linearize(char *outbuf, size_t len, DOM_SID *sid);
-int sid_compare(const DOM_SID *sid1, const DOM_SID *sid2);
-BOOL sid_equal(const DOM_SID *sid1, const DOM_SID *sid2);
-size_t sid_size(DOM_SID *sid);
+/*The following definitions come from  libsmb/passchange.c  */
 
-/*The following definitions come from  lib/util_sock.c  */
+BOOL remote_password_change(const char *remote_machine, const char *user_name, 
+                           const char *old_passwd, const char *new_passwd,
+                           char *err_str, size_t err_str_len);
 
-BOOL is_a_socket(int fd);
-void set_socket_options(int fd, char *options);
-ssize_t read_udp_socket(int fd,char *buf,size_t len);
-ssize_t read_with_timeout(int fd,char *buf,size_t mincnt,size_t maxcnt,unsigned int time_out);
-BOOL send_keepalive(int client);
-ssize_t read_data(int fd,char *buffer,size_t N);
-ssize_t write_data(int fd,char *buffer,size_t N);
-ssize_t write_socket_data(int fd,char *buffer,size_t N);
-ssize_t write_socket(int fd,char *buf,size_t len);
-ssize_t read_smb_length(int fd,char *inbuf,unsigned int timeout);
-BOOL receive_smb(int fd,char *buffer, unsigned int timeout);
-BOOL client_receive_smb(int fd,char *buffer, unsigned int timeout);
-BOOL send_null_session_msg(int fd);
-BOOL send_smb(int fd,char *buffer);
-BOOL send_one_packet(char *buf,int len,struct in_addr ip,int port,int type);
-int open_socket_in(int type, int port, int dlevel,uint32 socket_addr, BOOL rebind);
-int open_socket_out(int type, struct in_addr *addr, int port ,int timeout);
-void reset_globals_after_fork(void);
-void client_setfd(int fd);
-char *client_name(void);
-char *client_addr(void);
-char *get_socket_name(int fd);
-char *get_socket_addr(int fd);
-int open_pipe_sock(char *path);
-int create_pipe_socket(char *dir, int dir_perms,
-                               char *path, int path_perms);
+/*The following definitions come from  libsmb/pwd_cache.c  */
 
-/*The following definitions come from  lib/util_str.c  */
+void pwd_init(struct pwd_info *pwd);
+BOOL pwd_is_nullpwd(const struct pwd_info *pwd);
+BOOL pwd_compare(struct pwd_info *pwd1, struct pwd_info *pwd2);
+void pwd_read(struct pwd_info *pwd, char *passwd_report, BOOL do_encrypt);
+void pwd_set_nullpwd(struct pwd_info *pwd);
+void pwd_set_cleartext(struct pwd_info *pwd, char *clr);
+void pwd_get_cleartext(struct pwd_info *pwd, char *clr);
+void pwd_set_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]);
+void pwd_get_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]);
+void pwd_make_lm_nt_16(struct pwd_info *pwd, char *clr);
+void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8]);
+void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], uchar nt_owf[24]);
 
-void set_first_token(char *ptr);
-BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize);
-char **toktocliplist(int *ctok, char *sep);
-int StrCaseCmp(const char *s, const char *t);
-int StrnCaseCmp(const char *s, const char *t, size_t n);
-BOOL strequal(const char *s1, const char *s2);
-BOOL strnequal(const char *s1,const char *s2,size_t n);
-BOOL strcsequal(const char *s1,const char *s2);
-int strwicmp(char *psz1, char *psz2);
-void strlower(char *s);
-void strupper(char *s);
-void strnorm(char *s);
-BOOL strisnormal(char *s);
-void string_replace(char *s,char oldc,char newc);
-char *skip_string(char *buf,size_t n);
-size_t str_charnum(const char *s);
-BOOL trim_string(char *s,const char *front,const char *back);
-BOOL strhasupper(const char *s);
-BOOL strhaslower(const char *s);
-size_t count_chars(const char *s,char c);
-BOOL str_is_all(const char *s,char c);
-char *safe_strcpy(char *dest,const char *src, size_t maxlength);
-char *safe_strcat(char *dest, const char *src, size_t maxlength);
-char *alpha_strcpy(char *dest, const char *src, size_t maxlength);
-char *StrnCpy(char *dest,const char *src,size_t n);
-char *strncpyn(char *dest, const char *src,size_t n, char c);
-size_t strhex_to_str(char *p, size_t len, const char *strhex);
-BOOL in_list(char *s,char *list,BOOL casesensitive);
-void string_free(char **s);
-BOOL string_set(char **dest,const char *src);
-void string_sub(char *s,const char *pattern,const char *insert, size_t len);
-void fstring_sub(char *s,const char *pattern,const char *insert);
-void pstring_sub(char *s,const char *pattern,const char *insert);
-void all_string_sub(char *s,const char *pattern,const char *insert, size_t len);
-void split_at_last_component(char *path, char *front, char sep, char *back);
-char *octal_string(int i);
-char *string_truncate(char *s, int length);
-void parse_domain_user(char *domuser, fstring domain, fstring user);
+/*The following definitions come from  libsmb/smbdes.c  */
 
-/*The following definitions come from  lib/util_unistr.c  */
+void E_P16(unsigned char *p14,unsigned char *p16);
+void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24);
+void D_P16(unsigned char *p14, unsigned char *in, unsigned char *out);
+void E_old_pw_hash( unsigned char *p14, unsigned char *in, unsigned char *out);
+void cred_hash1(unsigned char *out,unsigned char *in,unsigned char *key);
+void cred_hash2(unsigned char *out,unsigned char *in,unsigned char *key);
+void cred_hash3(unsigned char *out,unsigned char *in,unsigned char *key, int forw);
+void SamOEMhash( unsigned char *data, unsigned char *key, int val);
 
-size_t dos_PutUniCode(char *dst,const char *src, ssize_t len, BOOL null_terminate);
-void unistr_to_dos(char *dest, const char *src, size_t len);
-char *skip_unibuf(char *src, size_t len);
-char *dos_unistrn2(uint16 *src, int len);
-char *dos_unistr2(uint16 *src);
-char *dos_unistr2_to_str(UNISTR2 *str);
-void ascii_to_unistr(uint16 *dest, const char *src, int maxlen);
-void unistr_to_ascii(char *dest, const uint16 *src, int len);
-void unistr2_to_ascii(char *dest, const UNISTR2 *str, size_t maxlen);
-uint32 buffer2_to_uint32(BUFFER2 *str);
-char *dos_buffer2_to_str(BUFFER2 *str);
-char *dos_buffer2_to_multistr(BUFFER2 *str);
-size_t dos_struni2(char *dst, const char *src, size_t max_len);
-char *dos_unistr(char *buf);
-int unistrcpy(char *dst, char *src);
-void default_unicode_map(smb_ucs2_t **pp_cp_to_ucs2, uint16 **pp_ucs2_to_cp);
-BOOL load_unicode_map(const char *codepage, smb_ucs2_t **pp_cp_to_ucs2, uint16 **pp_ucs2_to_cp);
-BOOL load_dos_unicode_map(int codepage);
-BOOL load_unix_unicode_map(const char *unix_char_set);
-smb_ucs2_t *multibyte_to_unicode(smb_ucs2_t *dst, const char *src,
-                                 size_t dst_len, smb_ucs2_t *cp_to_ucs2);
-char *unicode_to_unix(char *dst, const smb_ucs2_t *src, size_t dst_len);
-smb_ucs2_t *unix_to_unicode(smb_ucs2_t *dst, const char *src, size_t dst_len);
-char *unicode_to_dos(char *dst, const smb_ucs2_t *src, size_t dst_len);
-size_t unicode_to_dos_char(char *dst, const smb_ucs2_t src);
-smb_ucs2_t *dos_to_unicode(smb_ucs2_t *dst, const char *src, size_t dst_len);
-size_t strlen_w(const smb_ucs2_t *src);
-smb_ucs2_t *safe_strcpy_w(smb_ucs2_t *dest,const smb_ucs2_t *src, size_t maxlength);
-smb_ucs2_t *safe_strcat_w(smb_ucs2_t *dest, const smb_ucs2_t *src, size_t maxlength);
-int strcmp_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2);
-int strncmp_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2, size_t len);
-smb_ucs2_t *strstr_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2);
-smb_ucs2_t *strchr_w(const smb_ucs2_t *s, smb_ucs2_t c);
-smb_ucs2_t *strrchr_w(const smb_ucs2_t *s, smb_ucs2_t c);
-smb_ucs2_t *strtok_w(smb_ucs2_t *s1, const smb_ucs2_t *s2);
-smb_ucs2_t *strdup_w(const smb_ucs2_t *s);
-int isupper_w( smb_ucs2_t val);
-int islower_w( smb_ucs2_t val);
-int isdigit_w( smb_ucs2_t val);
-int isxdigit_w( smb_ucs2_t val);
-int isspace_w( smb_ucs2_t val);
-smb_ucs2_t toupper_w( smb_ucs2_t val );
-smb_ucs2_t tolower_w( smb_ucs2_t val );
-void set_first_token_w(smb_ucs2_t *ptr);
-BOOL next_token_w(smb_ucs2_t **ptr, smb_ucs2_t *buff, smb_ucs2_t *sep, size_t bufsize);
-smb_ucs2_t **toktocliplist_w(int *ctok, smb_ucs2_t *sep);
-int StrCaseCmp_w(const smb_ucs2_t *s, const smb_ucs2_t *t);
-int StrnCaseCmp_w(const smb_ucs2_t *s, const smb_ucs2_t *t, size_t n);
-BOOL strequal_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2);
-BOOL strnequal_w(const smb_ucs2_t *s1,const smb_ucs2_t *s2,size_t n);
-BOOL strcsequal_w(const smb_ucs2_t *s1,const smb_ucs2_t *s2);
-void strlower_w(smb_ucs2_t *s);
-void strupper_w(smb_ucs2_t *s);
-void strnorm_w(smb_ucs2_t *s);
-BOOL strisnormal_w(smb_ucs2_t *s);
-void string_replace_w(smb_ucs2_t *s, smb_ucs2_t oldc, smb_ucs2_t newc);
-smb_ucs2_t *skip_string_w(smb_ucs2_t *buf,size_t n);
-size_t str_charnum_w(const smb_ucs2_t *s);
-BOOL trim_string_w(smb_ucs2_t *s,const smb_ucs2_t *front,const smb_ucs2_t *back);
-BOOL strhasupper_w(const smb_ucs2_t *s);
-BOOL strhaslower_w(const smb_ucs2_t *s);
-size_t count_chars_w(const smb_ucs2_t *s,smb_ucs2_t c);
-BOOL str_is_all_w(const smb_ucs2_t *s,smb_ucs2_t c);
-smb_ucs2_t *alpha_strcpy_w(smb_ucs2_t *dest, const smb_ucs2_t *src, size_t maxlength);
-smb_ucs2_t *StrnCpy_w(smb_ucs2_t *dest,const smb_ucs2_t *src,size_t n);
-smb_ucs2_t *strncpyn_w(smb_ucs2_t *dest, const smb_ucs2_t *src,size_t n, smb_ucs2_t c);
-size_t strhex_to_str_w(char *p, size_t len, const smb_ucs2_t *strhex);
-BOOL in_list_w(smb_ucs2_t *s,smb_ucs2_t *list,BOOL casesensitive);
-BOOL string_init_w(smb_ucs2_t **dest,const smb_ucs2_t *src);
-void string_free_w(smb_ucs2_t **s);
-BOOL string_set_w(smb_ucs2_t **dest,const smb_ucs2_t *src);
-void string_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,const smb_ucs2_t *insert, size_t len);
-void fstring_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,const smb_ucs2_t *insert);
-void pstring_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,smb_ucs2_t *insert);
-void all_string_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,const smb_ucs2_t *insert, size_t len);
-void split_at_last_component_w(smb_ucs2_t *path, smb_ucs2_t *front, smb_ucs2_t sep, smb_ucs2_t *back);
-smb_ucs2_t *octal_string_w(int i);
-smb_ucs2_t *string_truncate_w(smb_ucs2_t *s, size_t length);
-smb_ucs2_t doscp2ucs2(int w);
-int ucs2doscp(smb_ucs2_t w);
+/*The following definitions come from  libsmb/smbencrypt.c  */
+
+void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24);
+void E_md4hash(uchar *passwd, uchar *p16);
+void nt_lm_owf_gen(char *pwd, uchar nt_p16[16], uchar p16[16]);
+void SMBOWFencrypt(uchar passwd[16], uchar *c8, uchar p24[24]);
+void NTLMSSPOWFencrypt(uchar passwd[8], uchar *ntlmchalresp, uchar p24[24]);
+void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24);
+BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[16], BOOL unicode);
+BOOL decode_pw_buffer(char buffer[516], char *new_pwrd,
+                     int new_pwrd_size, uint32 *new_pw_len);
 
-/*The following definitions come from  lib/wins_srv.c  */
+/*The following definitions come from  libsmb/smberr.c  */
 
-BOOL wins_srv_load_list( char *src );
-struct in_addr wins_srv_ip( void );
-void wins_srv_died( struct in_addr boothill_ip );
-unsigned long wins_srv_count( void );
+char *smb_errstr(char *inbuf);
+
+/*The following definitions come from  libsmb/unexpected.c  */
+
+void unexpected_packet(struct packet_struct *p);
+void clear_unexpected(time_t t);
+struct packet_struct *receive_unexpected(enum packet_type packet_type, int id, 
+                                        char *mailslot_name);
 
 /*The following definitions come from  locking/brlock.c  */
 
@@ -1169,6 +1166,9 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question,
                     struct name_record **n);
 void kill_async_dns_child(void);
 
+/*The following definitions come from  nmbd/nmbd.c  */
+
+
 /*The following definitions come from  nmbd/nmbd_become_dmb.c  */
 
 void add_domain_names(time_t t);
@@ -1199,9 +1199,6 @@ void announce_and_sync_with_domain_master_browser( struct subnet_record *subrec,
 void collect_all_workgroup_names_from_wins_server(time_t t);
 void sync_all_dmbs(time_t t);
 
-/*The following definitions come from  nmbd/nmbd.c  */
-
-
 /*The following definitions come from  nmbd/nmbd_elections.c  */
 
 void check_master_browser_exists(time_t t);
@@ -1963,7 +1960,6 @@ BOOL parse_lpq_entry(int snum,char *line,
 
 /*The following definitions come from  printing/nt_printing.c  */
 
-#if OLD_NTDOMAIN
 BOOL nt_printing_init(void);
 int get_ntforms(nt_forms_struct **list);
 int write_ntforms(nt_forms_struct **list, int number);
@@ -2002,7 +1998,6 @@ void map_printer_permissions(SEC_DESC *sd);
 BOOL print_access_check(struct current_user *user, int snum, int access_type);
 BOOL print_time_access_check(int snum);
 uint32 printer_write_default_dev(int snum, const PRINTER_DEFAULT *printer_default);
-#endif
 
 /*The following definitions come from  printing/pcap.c  */
 
@@ -2014,16 +2009,18 @@ void pcap_printer_fn(void (*fn)(char *, char *));
 void cups_printer_fn(void (*fn)(char *, char *));
 int cups_printername_ok(char *name);
 
+/*The following definitions come from  printing/print_svid.c  */
+
+void sysv_printer_fn(void (*fn)(char *, char *));
+int sysv_printername_ok(char *name);
+
 /*The following definitions come from  printing/printfsp.c  */
 
-#if OLD_NTDOMAIN
 files_struct *print_fsp_open(connection_struct *conn,char *jobname);
 void print_fsp_end(files_struct *fsp, BOOL normal_close);
-#endif
 
 /*The following definitions come from  printing/printing.c  */
 
-#if OLD_NTDOMAIN
 BOOL print_backend_init(void);
 BOOL print_job_exists(int jobid);
 int print_job_snum(int jobid);
@@ -2044,12 +2041,6 @@ int print_queue_snum(char *qname);
 BOOL print_queue_pause(struct current_user *user, int snum, int *errcode);
 BOOL print_queue_resume(struct current_user *user, int snum, int *errcode);
 BOOL print_queue_purge(struct current_user *user, int snum, int *errcode);
-#endif
-
-/*The following definitions come from  printing/print_svid.c  */
-
-void sysv_printer_fn(void (*fn)(char *, char *));
-int sysv_printername_ok(char *name);
 
 /*The following definitions come from  profile/profile.c  */
 
@@ -2170,7 +2161,6 @@ BOOL do_reg_close(struct cli_state *cli, POLICY_HND *hnd);
 
 /*The following definitions come from  rpc_client/cli_samr.c  */
 
-#if OLD_NTDOMAIN
 BOOL get_samr_query_usergroups(struct cli_state *cli, 
                                POLICY_HND *pol_open_domain, uint32 user_rid,
                                uint32 *num_groups, DOM_GID *gid);
@@ -2209,7 +2199,6 @@ BOOL do_samr_query_usergroups(struct cli_state *cli,
 BOOL do_samr_query_userinfo(struct cli_state *cli, 
                                POLICY_HND *pol, uint16 switch_value, void* usr);
 BOOL do_samr_close(struct cli_state *cli, POLICY_HND *hnd);
-#endif
 
 /*The following definitions come from  rpc_client/cli_spoolss_notify.c  */
 
@@ -2263,17 +2252,6 @@ BOOL do_wks_query_info(struct cli_state *cli,
                        char *server_name, uint32 switch_value,
                        WKS_INFO_100 *wks100);
 
-/*The following definitions come from  rpcclient/cmd_lsarpc.c  */
-
-
-/*The following definitions come from  rpcclient/cmd_samr.c  */
-
-#if NEW_NTDOMAIN
-#endif
-
-/*The following definitions come from  rpcclient/cmd_spoolss.c  */
-
-
 /*The following definitions come from  rpc_client/ncacn_np_use.c  */
 
 BOOL ncacn_np_use_del(const char *srv_name, const char *pipe_name,
@@ -2287,12 +2265,6 @@ struct ncacn_np *ncacn_np_use_add(const char *pipe_name,
                                   const struct ntuser_creds *ntc,
                                   BOOL reuse, BOOL *is_new_connection);
 
-/*The following definitions come from  rpcclient/rpcclient.c  */
-
-void fetch_domain_sid(void);
-void init_rpcclient_creds(struct ntuser_creds *creds);
-void add_command_set(struct cmd_set *cmd_set);
-
 /*The following definitions come from  rpc_parse/parse_creds.c  */
 
 BOOL make_creds_unix(CREDS_UNIX *r_u, const char* user_name,
@@ -2531,13 +2503,12 @@ void init_sam_info(DOM_SAM_INFO *sam,
                                char *logon_srv, char *comp_name, DOM_CRED *clnt_cred,
                                DOM_CRED *rtn_cred, uint16 logon_level,
                                NET_ID_INFO_CTR *ctr);
-void init_net_user_info3(NET_USER_INFO_3 *usr, SAM_ACCOUNT *sampw,
+void init_net_user_info3(TALLOC_CTX *ctx, NET_USER_INFO_3 *usr, SAM_ACCOUNT *sampw,
                         uint16 logon_count, uint16 bad_pw_count,
                         uint32 num_groups, DOM_GID *gids,
                         uint32 user_flgs, char *sess_key,
                         char *logon_srv, char *logon_dom,
                         DOM_SID *dom_sid, char *other_sids);
-void free_user_info3(NET_USER_INFO_3 *usr);
 BOOL net_io_q_sam_logon(char *desc, NET_Q_SAM_LOGON *q_l, prs_struct *ps, int depth);
 BOOL net_io_r_sam_logon(char *desc, NET_R_SAM_LOGON *r_l, prs_struct *ps, int depth);
 BOOL net_io_q_sam_logoff(char *desc,  NET_Q_SAM_LOGOFF *q_l, prs_struct *ps, int depth);
@@ -2716,273 +2687,459 @@ BOOL smb_io_rpc_auth_ntlmssp_chk(char *desc, RPC_AUTH_NTLMSSP_CHK *chk, prs_stru
 
 /*The following definitions come from  rpc_parse/parse_samr.c  */
 
-#if OLD_NTDOMAIN
-void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND *q_c, POLICY_HND *hnd);
-BOOL samr_io_q_close_hnd(char *desc,  SAMR_Q_CLOSE_HND *q_u, prs_struct *ps, int depth);
-BOOL samr_io_r_close_hnd(char *desc,  SAMR_R_CLOSE_HND *r_u, prs_struct *ps, int depth);
-void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, 
-                            POLICY_HND *connect_pol, 
-                            uint32 access_mask, DOM_SID *sid);
-BOOL samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN *q_u, prs_struct *ps, int depth);
-BOOL samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN *r_u, prs_struct *ps, int depth);
-void init_samr_q_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, POLICY_HND *user_pol);
-BOOL samr_io_q_unknown_2c(char *desc,  SAMR_Q_UNKNOWN_2C *q_u, prs_struct *ps, int depth);
-void init_samr_r_unknown_2c(SAMR_R_UNKNOWN_2C *q_u, uint32 status);
-BOOL samr_io_r_unknown_2c(char *desc,  SAMR_R_UNKNOWN_2C *r_u, prs_struct *ps, int depth);
-void init_samr_q_unknown_3(SAMR_Q_UNKNOWN_3 *q_u,
-                               POLICY_HND *user_pol, uint16 switch_value);
-BOOL samr_io_q_unknown_3(char *desc,  SAMR_Q_UNKNOWN_3 *q_u, prs_struct *ps, int depth);
-void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u,
-                               POLICY_HND *domain_pol, uint16 switch_value);
-BOOL samr_io_q_query_dom_info(char *desc,  SAMR_Q_QUERY_DOMAIN_INFO *q_u, prs_struct *ps, int depth);
-BOOL init_unk_info1(SAM_UNK_INFO_1 *u_1);
-void init_unk_info2(SAM_UNK_INFO_2 *u_2, char *domain, char *server);
-BOOL sam_io_unk_info2(char *desc, SAM_UNK_INFO_2 *u_2, prs_struct *ps, int depth);
-BOOL init_unk_info3(SAM_UNK_INFO_3 * u_3);
-BOOL init_unk_info6(SAM_UNK_INFO_6 * u_6);
-BOOL init_unk_info7(SAM_UNK_INFO_7 *u_7);
-BOOL init_unk_info12(SAM_UNK_INFO_12 * u_12);
-void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO *r_u, 
-                               uint16 switch_value, SAM_UNK_CTR *ctr,
-                               uint32 status);
-BOOL samr_io_r_query_dom_info(char *desc, SAMR_R_QUERY_DOMAIN_INFO *r_u, prs_struct *ps, int depth);
-void init_dom_sid3(DOM_SID3 *sid3, uint16 unk_0, uint16 unk_1, DOM_SID *sid);
-void init_samr_r_unknown_3(SAMR_R_UNKNOWN_3 *r_u,
-                               uint16 unknown_2, uint16 unknown_3,
-                               uint32 unknown_4, uint16 unknown_6, uint16 unknown_7,
-                               int num_sid3s, DOM_SID3 sid3[MAX_SAM_SIDS],
-                               uint32 status);
-BOOL samr_io_r_unknown_3(char *desc,  SAMR_R_UNKNOWN_3 *r_u, prs_struct *ps, int depth);
-void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_e, POLICY_HND *pol,
-                               uint16 req_num_entries, uint16 unk_0,
-                               uint16 acb_mask, uint16 unk_1, uint32 size);
-BOOL samr_io_q_enum_dom_users(char *desc,  SAMR_Q_ENUM_DOM_USERS *q_e, prs_struct *ps, int depth);
-void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS *r_u,
-               uint16 total_num_entries, uint16 unk_0,
-               uint32 num_sam_entries, SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES], uint32 status);
-BOOL samr_io_r_enum_dom_users(char *desc,  SAMR_R_ENUM_DOM_USERS *r_u, prs_struct *ps, int depth);
-void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_e, POLICY_HND *pol, uint32 size);
-BOOL samr_io_q_enum_dom_aliases(char *desc,  SAMR_Q_ENUM_DOM_ALIASES *q_e, prs_struct *ps, int depth);
-void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u,
-               uint32 num_sam_entries, SAM_USER_INFO_21 grps[MAX_SAM_ENTRIES],
-               uint32 status);
-BOOL samr_io_r_enum_dom_aliases(char *desc,  SAMR_R_ENUM_DOM_ALIASES *r_u, prs_struct *ps, int depth);
-void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_e, POLICY_HND *pol,
-                               uint16 switch_level, uint32 start_idx, uint32 size);
-BOOL samr_io_q_query_dispinfo(char *desc,  SAMR_Q_QUERY_DISPINFO *q_e, prs_struct *ps, int depth);
-void init_sam_info_2(SAM_INFO_2 *sam, uint32 acb_mask,
-               uint32 start_idx, uint32 num_sam_entries,
-               SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]);
-void init_sam_info_1(SAM_INFO_1 *sam, uint32 acb_mask,
-               uint32 start_idx, uint32 num_sam_entries,
-               SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]);
-void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO *r_u,
-               uint16 switch_level, SAM_INFO_CTR *ctr, uint32 status);
-BOOL samr_io_r_query_dispinfo(char *desc,  SAMR_R_QUERY_DISPINFO *r_u, prs_struct *ps, int depth);
-void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_e, POLICY_HND *pol,
-                               uint16 switch_level, uint32 start_idx, uint32 size);
-BOOL samr_io_q_enum_dom_groups(char *desc,  SAMR_Q_ENUM_DOM_GROUPS *q_e, prs_struct *ps, int depth);
-void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS *r_u,
-               uint32 start_idx, uint32 num_sam_entries,
-               SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES],
-               uint32 status);
-BOOL samr_io_r_enum_dom_groups(char *desc,  SAMR_R_ENUM_DOM_GROUPS *r_u, prs_struct *ps, int depth);
-void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_e,
-                               POLICY_HND *pol,
-                               uint16 switch_level);
-BOOL samr_io_q_query_aliasinfo(char *desc,  SAMR_Q_QUERY_ALIASINFO *q_e, prs_struct *ps, int depth);
-void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *r_u, uint32 switch_level,
-                                char* alias, char* alias_desc);
-BOOL samr_io_r_query_aliasinfo(char *desc,  SAMR_R_QUERY_ALIASINFO *r_u, prs_struct *ps, int depth);
-BOOL samr_io_q_lookup_ids(char *desc,  SAMR_Q_LOOKUP_IDS *q_u, prs_struct *ps, int depth);
-void init_samr_r_lookup_ids(SAMR_R_LOOKUP_IDS *r_u,
-               uint32 num_rids, uint32 *rid, uint32 status);
-BOOL samr_io_r_lookup_ids(char *desc,  SAMR_R_LOOKUP_IDS *r_u, prs_struct *ps, int depth);
-BOOL samr_io_q_lookup_names(char *desc,  SAMR_Q_LOOKUP_NAMES *q_u, prs_struct *ps, int depth);
-void init_samr_r_lookup_names(SAMR_R_LOOKUP_NAMES *r_u,
-                       uint32 num_rids, uint32 *rid, enum SID_NAME_USE *type, uint32 status);
-BOOL samr_io_r_lookup_names(char *desc,  SAMR_R_LOOKUP_NAMES *r_u, prs_struct *ps, int depth);
-BOOL samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS *q_u, prs_struct *ps, int depth);
-void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS *r_u,
-               uint32 num_aliases, fstring *als_name, uint32 *num_als_usrs,
-               uint32 status);
-BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS *r_u, prs_struct *ps, int depth);
-void init_samr_q_open_user(SAMR_Q_OPEN_USER *q_u, POLICY_HND *pol,
-                          uint32 access_mask, uint32 rid);
-BOOL samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER *q_u, 
-                        prs_struct *ps, int depth);
-BOOL samr_io_r_open_user(char *desc,  SAMR_R_OPEN_USER *r_u, prs_struct *ps, int depth);
-void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u,
-                               POLICY_HND *hnd);
-BOOL samr_io_q_query_usergroups(char *desc,  SAMR_Q_QUERY_USERGROUPS *q_u, prs_struct *ps, int depth);
-void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS *r_u,
-               uint32 num_gids, DOM_GID *gid, uint32 status);
-BOOL samr_io_r_query_usergroups(char *desc,  SAMR_R_QUERY_USERGROUPS *r_u, prs_struct *ps, int depth);
-void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u,
-                               POLICY_HND *hnd, uint16 switch_value);
-BOOL samr_io_q_query_userinfo(char *desc,  SAMR_Q_QUERY_USERINFO *q_u, prs_struct *ps, int depth);
-void init_sam_user_info10(SAM_USER_INFO_10 *usr,
-                               uint32 acb_info);
-BOOL sam_io_user_info10(char *desc,  SAM_USER_INFO_10 *usr, prs_struct *ps, int depth);
-void init_sam_user_info11(SAM_USER_INFO_11 *usr,
-                               NTTIME *expiry,
-                               char *mach_acct,
-                               uint32 rid_user,
-                               uint32 rid_group,
-                               uint16 acct_ctrl);
-BOOL sam_io_user_info11(char *desc,  SAM_USER_INFO_11 *usr, prs_struct *ps, int depth);
-void init_sam_user_info21(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw);
-void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO *r_u,
-                               uint16 switch_value, void *info, uint32 status);
-BOOL samr_io_r_query_userinfo(char *desc, SAMR_R_QUERY_USERINFO *r_u, 
-                             prs_struct *ps, int depth);
-BOOL samr_io_q_create_user(char *desc, SAMR_Q_CREATE_USER *q_u, prs_struct *ps, int depth);
-BOOL samr_io_r_create_user(char *desc, SAMR_R_CREATE_USER *r_u, prs_struct *ps, int depth);
-void init_samr_q_connect(SAMR_Q_CONNECT *q_u, char *srv_name, 
-                        uint32 access_mask);
-BOOL samr_io_q_connect(char *desc,  SAMR_Q_CONNECT *q_u, prs_struct *ps, int depth);
-BOOL samr_io_r_connect(char *desc,  SAMR_R_CONNECT *r_u, prs_struct *ps, int depth);
-void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON *q_u);
-BOOL samr_io_q_connect_anon(char *desc,  SAMR_Q_CONNECT_ANON *q_u, prs_struct *ps, int depth);
-BOOL samr_io_r_connect_anon(char *desc,  SAMR_R_CONNECT_ANON *r_u, prs_struct *ps, int depth);
-void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS *q_u,
-                               uint32 unknown_0, uint32 rid);
-BOOL samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS *q_u, prs_struct *ps, int depth);
-BOOL samr_io_r_open_alias(char *desc,  SAMR_R_OPEN_ALIAS *r_u, prs_struct *ps, int depth);
-void init_samr_q_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u,
-               POLICY_HND *pol, uint32 rid,
-               uint32 num_gids, uint32 *gid);
-void init_samr_q_unknown_21(SAMR_Q_UNKNOWN_21 *q_c,
-                               POLICY_HND *hnd, uint16 unk_1, uint16 unk_2);
-void init_samr_q_unknown_13(SAMR_Q_UNKNOWN_13 *q_c,
-                               POLICY_HND *hnd, uint16 unk_1, uint16 unk_2);
-void init_samr_q_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, char *srv_name);
-BOOL samr_io_q_unknown_38(char *desc,  SAMR_Q_UNKNOWN_38 *q_u, prs_struct *ps, int depth);
-void init_samr_r_unknown_38(SAMR_R_UNKNOWN_38 *r_u);
-BOOL samr_io_r_unknown_38(char *desc,  SAMR_R_UNKNOWN_38 *r_u, prs_struct *ps, int depth);
-void init_enc_passwd(SAMR_ENC_PASSWD *pwd, char pass[512]);
-BOOL samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD *pwd, prs_struct *ps, int depth);
-void init_enc_hash(SAMR_ENC_HASH *hsh, uchar hash[16]);
-BOOL samr_io_enc_hash(char *desc, SAMR_ENC_HASH *hsh, prs_struct *ps, int depth);
-void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u,
-                               char *dest_host, char *user_name,
-                               char nt_newpass[516], uchar nt_oldhash[16],
-                               char lm_newpass[516], uchar lm_oldhash[16]);
-BOOL samr_io_q_chgpasswd_user(char *desc, SAMR_Q_CHGPASSWD_USER *q_u, prs_struct *ps, int depth);
-void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER *r_u, uint32 status);
-BOOL samr_io_r_chgpasswd_user(char *desc, SAMR_R_CHGPASSWD_USER *r_u, prs_struct *ps, int depth);
-BOOL samr_io_q_lookup_domain(char* desc, SAMR_Q_LOOKUP_DOMAIN* q_u, prs_struct *ps, int depth);
-BOOL init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
-                               DOM_SID *dom_sid, uint32 status);
-BOOL samr_io_r_lookup_domain(char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
-                             prs_struct *ps, int depth);
-BOOL samr_io_q_enum_domains(char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
-                            prs_struct *ps, int depth);
-BOOL init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
-                              uint32 next_idx, fstring* domains, uint32 num_sam_entries);
-BOOL samr_io_r_enum_domains(char *desc, SAMR_R_ENUM_DOMAINS * r_u,
-                            prs_struct *ps, int depth);
-void free_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr);
-BOOL samr_io_q_set_userinfo(char *desc, SAMR_Q_SET_USERINFO *q_u, prs_struct *ps, int depth);
-void free_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u);
-BOOL samr_io_r_set_userinfo(char *desc, SAMR_R_SET_USERINFO *r_u, prs_struct *ps, int depth);
-BOOL samr_io_q_set_userinfo2(char *desc, SAMR_Q_SET_USERINFO2 *q_u, prs_struct *ps, int depth);
-void free_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 *q_u);
-BOOL make_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 *r_u, uint32 status);
-BOOL samr_io_r_set_userinfo2(char *desc, SAMR_R_SET_USERINFO2 *r_u, prs_struct *ps, int depth);
-#endif
-
-/*The following definitions come from  rpc_parse/parse_samr_new.c  */
-
-#if NEW_NTDOMAIN
-BOOL init_samr_q_connect(SAMR_Q_CONNECT * q_u, char *srv_name, 
-                        uint32 access_mask);
-BOOL samr_io_q_connect(char *desc, SAMR_Q_CONNECT * q_u, prs_struct *ps, 
-                      int depth);
-BOOL samr_io_r_connect(char *desc, SAMR_R_CONNECT * r_u, prs_struct *ps, 
-                      int depth);
-BOOL init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd);
+void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd);
 BOOL samr_io_q_close_hnd(char *desc, SAMR_Q_CLOSE_HND * q_u,
                         prs_struct *ps, int depth);
 BOOL samr_io_r_close_hnd(char *desc, SAMR_R_CLOSE_HND * r_u,
                         prs_struct *ps, int depth);
-BOOL init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u, 
-                            POLICY_HND *connect_pol, uint32 access_mask,
+void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
+                              POLICY_HND *pol, char *dom_name);
+BOOL samr_io_q_lookup_domain(char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
+                            prs_struct *ps, int depth);
+void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
+                              DOM_SID *dom_sid, uint32 status);
+BOOL samr_io_r_lookup_domain(char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
+                            prs_struct *ps, int depth);
+void init_samr_q_unknown_2d(SAMR_Q_UNKNOWN_2D * q_u, POLICY_HND *dom_pol, DOM_SID *sid);
+BOOL samr_io_q_unknown_2d(char *desc, SAMR_Q_UNKNOWN_2D * q_u,
+                         prs_struct *ps, int depth);
+BOOL samr_io_r_unknown_2d(char *desc, SAMR_R_UNKNOWN_2D * r_u,
+                         prs_struct *ps, int depth);
+void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
+                            POLICY_HND *pol, uint32 flags,
                             DOM_SID *sid);
 BOOL samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
                           prs_struct *ps, int depth);
 BOOL samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN * r_u,
                           prs_struct *ps, int depth);
-BOOL init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u, POLICY_HND *pol,
-                          uint32 access_mask, uint32 rid);
-BOOL samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER * q_u,
-                        prs_struct *ps, int depth);
-BOOL samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER * r_u,
-                        prs_struct *ps, int depth);
-BOOL init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
-                               POLICY_HND *hnd, uint16 switch_value);
-BOOL samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO * q_u,
+void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
+                                  POLICY_HND *user_pol);
+BOOL samr_io_q_get_usrdom_pwinfo(char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
+                                prs_struct *ps, int depth);
+void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, uint32 status);
+BOOL samr_io_r_get_usrdom_pwinfo(char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
+                                prs_struct *ps, int depth);
+void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
+                              POLICY_HND *user_pol, uint32 sec_info);
+BOOL samr_io_q_query_sec_obj(char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
+                            prs_struct *ps, int depth);
+void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
+                               POLICY_HND *domain_pol, uint16 switch_value);
+BOOL samr_io_q_query_dom_info(char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
                              prs_struct *ps, int depth);
-BOOL samr_io_r_query_userinfo(char *desc, SAMR_R_QUERY_USERINFO * r_u,
+void init_unk_info3(SAM_UNK_INFO_3 * u_3);
+void init_unk_info6(SAM_UNK_INFO_6 * u_6);
+void init_unk_info7(SAM_UNK_INFO_7 * u_7);
+void init_unk_info12(SAM_UNK_INFO_12 * u_12);
+void init_unk_info2(SAM_UNK_INFO_2 * u_2,
+                       char *domain, char *server,
+                       uint32 seq_num);
+void init_unk_info1(SAM_UNK_INFO_1 * u_1);
+void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
+                               uint16 switch_value, SAM_UNK_CTR * ctr,
+                               uint32 status);
+BOOL samr_io_r_query_dom_info(char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
                              prs_struct *ps, int depth);
-BOOL samr_io_userinfo_ctr(char *desc, SAM_USERINFO_CTR * ctr,
-                                prs_struct *ps, int depth);
-void free_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr);
-BOOL sam_io_user_info10(char *desc, SAM_USER_INFO_10 * usr,
-                       prs_struct *ps, int depth);
-BOOL init_sam_user_info11(SAM_USER_INFO_11 * usr,
-                         NTTIME * expiry,
-                         char *mach_acct,
-                         uint32 rid_user, uint32 rid_group, uint16 acct_ctrl);
-BOOL sam_io_user_info11(char *desc, SAM_USER_INFO_11 * usr,
-                       prs_struct *ps, int depth);
-BOOL sam_io_user_info12(char *desc, SAM_USER_INFO_12 * u,
-                       prs_struct *ps, int depth);
-BOOL sam_io_user_info21(char *desc, SAM_USER_INFO_21 * usr,
-                       prs_struct *ps, int depth);
-BOOL sam_io_user_info23(char *desc, SAM_USER_INFO_23 * usr,
-                       prs_struct *ps, int depth);
-BOOL init_sam_user_info24(SAM_USER_INFO_24 * usr,
-                         const char newpass[516], uint16 passlen);
-BOOL sam_io_user_info24(char *desc, SAM_USER_INFO_24 * usr,
-                       prs_struct *ps, int depth);
-BOOL sam_io_logon_hrs(char *desc, LOGON_HRS * hrs, prs_struct *ps, 
-                     int depth);
-BOOL init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
+BOOL samr_io_r_query_sec_obj(char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
+                            prs_struct *ps, int depth);
+void init_sam_entry(SAM_ENTRY * sam, uint32 len_sam_name, uint32 rid);
+void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
+                               uint32 start_idx,
+                               uint16 acb_mask, uint16 unk_1, uint32 size);
+BOOL samr_io_q_enum_dom_users(char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
+                             prs_struct *ps, int depth);
+void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
+                               uint32 next_idx, uint32 num_sam_entries);
+BOOL samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
+                             prs_struct *ps, int depth);
+void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
+                               uint16 switch_level, uint32 start_idx,
+                               uint32 max_entries);
+BOOL samr_io_q_query_dispinfo(char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
+                             prs_struct *ps, int depth);
+void init_sam_dispinfo_1(SAM_DISPINFO_1 * sam, uint32 *num_entries,
+                        uint32 *data_size, uint32 start_idx,
+                        SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]);
+void init_sam_dispinfo_2(SAM_DISPINFO_2 * sam, uint32 *num_entries,
+                        uint32 *data_size, uint32 start_idx,
+                        SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]);
+void init_sam_dispinfo_3(SAM_DISPINFO_3 * sam, uint32 *num_entries,
+                        uint32 *data_size, uint32 start_idx,
+                        DOMAIN_GRP * grp);
+void init_sam_dispinfo_4(SAM_DISPINFO_4 * sam, uint32 *num_entries,
+                        uint32 *data_size, uint32 start_idx,
+                        SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]);
+void init_sam_dispinfo_5(SAM_DISPINFO_5 * sam, uint32 *num_entries,
+                        uint32 *data_size, uint32 start_idx,
+                        DOMAIN_GRP * grp);
+void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
+                               uint32 num_entries, uint32 data_size,
+                               uint16 switch_level, SAM_DISPINFO_CTR * ctr,
+                               uint32 status);
+BOOL samr_io_r_query_dispinfo(char *desc, SAMR_R_QUERY_DISPINFO * r_u,
+                             prs_struct *ps, int depth);
+void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
+                           POLICY_HND *hnd,
+                           uint32 access_mask, uint32 rid);
+BOOL samr_io_q_open_group(char *desc, SAMR_Q_OPEN_GROUP * q_u,
+                         prs_struct *ps, int depth);
+BOOL samr_io_r_open_group(char *desc, SAMR_R_OPEN_GROUP * r_u,
+                         prs_struct *ps, int depth);
+void init_samr_group_info1(GROUP_INFO1 * gr1,
+                          char *acct_name, char *acct_desc,
+                          uint32 num_members);
+BOOL samr_io_group_info1(char *desc, GROUP_INFO1 * gr1,
+                        prs_struct *ps, int depth);
+void init_samr_group_info4(GROUP_INFO4 * gr4, char *acct_desc);
+BOOL samr_io_group_info4(char *desc, GROUP_INFO4 * gr4,
+                        prs_struct *ps, int depth);
+void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
+                                 POLICY_HND *pol, char *acct_desc,
+                                 uint32 access_mask);
+BOOL samr_io_q_create_dom_group(char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
+                               prs_struct *ps, int depth);
+BOOL samr_io_r_create_dom_group(char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
+                               prs_struct *ps, int depth);
+void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
+                                 POLICY_HND *hnd);
+BOOL samr_io_q_delete_dom_group(char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
+                               prs_struct *ps, int depth);
+BOOL samr_io_r_delete_dom_group(char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
+                               prs_struct *ps, int depth);
+void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
+                             POLICY_HND *pol, uint32 rid);
+BOOL samr_io_q_del_groupmem(char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
+                           prs_struct *ps, int depth);
+void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
+                             uint32 status);
+BOOL samr_io_r_del_groupmem(char *desc, SAMR_R_DEL_GROUPMEM * r_u,
+                           prs_struct *ps, int depth);
+void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
+                             POLICY_HND *pol, uint32 rid);
+BOOL samr_io_q_add_groupmem(char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
+                           prs_struct *ps, int depth);
+void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
+                             uint32 status);
+BOOL samr_io_r_add_groupmem(char *desc, SAMR_R_ADD_GROUPMEM * r_u,
+                           prs_struct *ps, int depth);
+void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
+                              POLICY_HND *pol, GROUP_INFO_CTR * ctr);
+BOOL samr_io_q_set_groupinfo(char *desc, SAMR_Q_SET_GROUPINFO * q_e,
+                            prs_struct *ps, int depth);
+void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, uint32 status);
+BOOL samr_io_r_set_groupinfo(char *desc, SAMR_R_SET_GROUPINFO * r_u,
+                            prs_struct *ps, int depth);
+void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
                                 POLICY_HND *pol, uint16 switch_level);
 BOOL samr_io_q_query_groupinfo(char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
                               prs_struct *ps, int depth);
+void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
+                                GROUP_INFO_CTR * ctr, uint32 status);
 BOOL samr_io_r_query_groupinfo(char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
                               prs_struct *ps, int depth);
-BOOL samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u, 
-                                 POLICY_HND *hnd);
-BOOL samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
-                               prs_struct *ps, int depth);
-BOOL samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
-                               prs_struct *ps, int depth);
-BOOL init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd);
+void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd);
 BOOL samr_io_q_query_groupmem(char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
                              prs_struct *ps, int depth);
+void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
+                               uint32 num_entries, uint32 *rid,
+                               uint32 *attr, uint32 status);
 BOOL samr_io_r_query_groupmem(char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
                              prs_struct *ps, int depth);
-void samr_free_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u);
-BOOL samr_group_info_ctr(char *desc, GROUP_INFO_CTR * ctr, prs_struct *ps, 
-                        int depth);
+void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
+                                 POLICY_HND *hnd);
+BOOL samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
+                               prs_struct *ps, int depth);
+void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
+                                 uint32 num_gids, DOM_GID * gid,
+                                 uint32 status);
 BOOL samr_io_gids(char *desc, uint32 *num_gids, DOM_GID ** gid,
                  prs_struct *ps, int depth);
-BOOL samr_io_group_info1(char *desc, GROUP_INFO1 * gr1,
+BOOL samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
+                               prs_struct *ps, int depth);
+void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
+                             POLICY_HND *pol,
+                             uint32 start_idx, uint32 size);
+BOOL samr_io_q_enum_domains(char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
+                           prs_struct *ps, int depth);
+void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
+                             uint32 next_idx, uint32 num_sam_entries);
+BOOL samr_io_r_enum_domains(char *desc, SAMR_R_ENUM_DOMAINS * r_u,
+                           prs_struct *ps, int depth);
+void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
+                                POLICY_HND *pol,
+                                uint32 start_idx, uint32 size);
+BOOL samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
+                              prs_struct *ps, int depth);
+void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
+                                uint32 next_idx, uint32 num_sam_entries);
+BOOL samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
+                              prs_struct *ps, int depth);
+void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
+                                 POLICY_HND *pol, uint32 start_idx,
+                                 uint32 size);
+BOOL samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
+                               prs_struct *ps, int depth);
+void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries);
+BOOL samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
+                               prs_struct *ps, int depth);
+void init_samr_alias_info3(ALIAS_INFO3 * al3, char *acct_desc);
+BOOL samr_io_alias_info3(char *desc, ALIAS_INFO3 * al3,
                         prs_struct *ps, int depth);
-BOOL samr_io_group_info4(char *desc, GROUP_INFO4 * gr4,
+BOOL samr_alias_info_ctr(char *desc, ALIAS_INFO_CTR * ctr,
                         prs_struct *ps, int depth);
-BOOL init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
-                                 POLICY_HND *hnd);
-BOOL init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c, POLICY_HND *hnd,
-                           uint32 access_mask, uint32 rid);
-BOOL samr_io_q_open_group(char *desc, SAMR_Q_OPEN_GROUP * q_u,
+void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
+                                POLICY_HND *pol, uint16 switch_level);
+BOOL samr_io_q_query_aliasinfo(char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
+                              prs_struct *ps, int depth);
+void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
+                                ALIAS_INFO_CTR * ctr, uint32 status);
+BOOL samr_io_r_query_aliasinfo(char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
+                              prs_struct *ps, int depth);
+void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
+                              POLICY_HND *hnd, ALIAS_INFO_CTR * ctr);
+BOOL samr_io_q_set_aliasinfo(char *desc, SAMR_Q_SET_ALIASINFO * q_u,
+                            prs_struct *ps, int depth);
+BOOL samr_io_r_set_aliasinfo(char *desc, SAMR_R_SET_ALIASINFO * r_u,
+                            prs_struct *ps, int depth);
+void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
+                                  POLICY_HND *hnd,
+                                  uint32 num_sids,
+                                  uint32 *ptr_sid, DOM_SID2 * sid);
+BOOL samr_io_q_query_useraliases(char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
+                                prs_struct *ps, int depth);
+void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
+                                  uint32 num_rids, uint32 *rid,
+                                  uint32 status);
+BOOL samr_io_rids(char *desc, uint32 *num_rids, uint32 **rid,
+                 prs_struct *ps, int depth);
+BOOL samr_io_r_query_useraliases(char *desc, SAMR_R_QUERY_USERALIASES * r_u,
+                                prs_struct *ps, int depth);
+void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
+                           uint32 unknown_0, uint32 rid);
+BOOL samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS * q_u,
                          prs_struct *ps, int depth);
-BOOL samr_io_r_open_group(char *desc, SAMR_R_OPEN_GROUP * r_u,
+BOOL samr_io_r_open_alias(char *desc, SAMR_R_OPEN_ALIAS * r_u,
                          prs_struct *ps, int depth);
-#endif
+void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
+                            POLICY_HND *pol, uint32 flags,
+                            uint32 num_rids, uint32 *rid);
+BOOL samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
+                          prs_struct *ps, int depth);
+void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
+                            uint32 num_names, UNIHDR * hdr_name,
+                            UNISTR2 *uni_name, uint32 *type);
+BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS * r_u,
+                          prs_struct *ps, int depth);
+void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd);
+BOOL samr_io_q_delete_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
+                           prs_struct *ps, int depth);
+BOOL samr_io_r_delete_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
+                           prs_struct *ps, int depth);
+void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
+                                 POLICY_HND *hnd, char *acct_desc);
+BOOL samr_io_q_create_dom_alias(char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
+                               prs_struct *ps, int depth);
+BOOL samr_io_r_create_dom_alias(char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
+                               prs_struct *ps, int depth);
+void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
+                             DOM_SID *sid);
+BOOL samr_io_q_add_aliasmem(char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
+                           prs_struct *ps, int depth);
+BOOL samr_io_r_add_aliasmem(char *desc, SAMR_R_ADD_ALIASMEM * r_u,
+                           prs_struct *ps, int depth);
+void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
+                             DOM_SID *sid);
+BOOL samr_io_q_del_aliasmem(char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
+                           prs_struct *ps, int depth);
+BOOL samr_io_r_del_aliasmem(char *desc, SAMR_R_DEL_ALIASMEM * r_u,
+                           prs_struct *ps, int depth);
+void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
+                                 POLICY_HND *hnd);
+BOOL samr_io_q_delete_dom_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
+                               prs_struct *ps, int depth);
+void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
+                                 uint32 status);
+BOOL samr_io_r_delete_dom_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
+                               prs_struct *ps, int depth);
+void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
+                               POLICY_HND *hnd);
+BOOL samr_io_q_query_aliasmem(char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
+                             prs_struct *ps, int depth);
+void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
+                               uint32 num_sids, DOM_SID2 * sid,
+                               uint32 status);
+BOOL samr_io_r_query_aliasmem(char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
+                             prs_struct *ps, int depth);
+void init_samr_q_lookup_names(SAMR_Q_LOOKUP_NAMES * q_u,
+                             POLICY_HND *pol, uint32 flags,
+                             uint32 num_names, char **name);
+BOOL samr_io_q_lookup_names(char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
+                           prs_struct *ps, int depth);
+void init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
+                             uint32 num_rids,
+                             uint32 *rid, uint32 *type,
+                             uint32 status);
+BOOL samr_io_r_lookup_names(char *desc, SAMR_R_LOOKUP_NAMES * r_u,
+                           prs_struct *ps, int depth);
+void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
+                                POLICY_HND *hnd);
+BOOL samr_io_q_delete_dom_user(char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
+                              prs_struct *ps, int depth);
+BOOL samr_io_r_delete_dom_user(char *desc, SAMR_R_DELETE_DOM_USER * r_u,
+                              prs_struct *ps, int depth);
+void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
+                          POLICY_HND *pol,
+                          uint32 access_mask, uint32 rid);
+BOOL samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER * q_u,
+                        prs_struct *ps, int depth);
+BOOL samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER * r_u,
+                        prs_struct *ps, int depth);
+void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
+                            POLICY_HND *pol,
+                            char *name,
+                            uint32 acb_info, uint32 access_mask);
+BOOL samr_io_q_create_user(char *desc, SAMR_Q_CREATE_USER * q_u,
+                          prs_struct *ps, int depth);
+BOOL samr_io_r_create_user(char *desc, SAMR_R_CREATE_USER * r_u,
+                          prs_struct *ps, int depth);
+void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
+                               POLICY_HND *hnd, uint16 switch_value);
+BOOL samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO * q_u,
+                             prs_struct *ps, int depth);
+void init_sam_user_info12(SAM_USER_INFO_12 * usr,
+                         uint8 lm_pwd[16], uint8 nt_pwd[16]);
+void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info);
+void init_sam_user_info11(SAM_USER_INFO_11 * usr,
+                         NTTIME * expiry,
+                         char *mach_acct,
+                         uint32 rid_user, uint32 rid_group, uint16 acct_ctrl);
+void init_sam_user_info24(SAM_USER_INFO_24 * usr,
+                         char newpass[516], uint16 passlen);
+void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time,        /* all zeros */
+                       NTTIME * logoff_time,   /* all zeros */
+                       NTTIME * kickoff_time,  /* all zeros */
+                       NTTIME * pass_last_set_time,    /* all zeros */
+                       NTTIME * pass_can_change_time,  /* all zeros */
+                       NTTIME * pass_must_change_time, /* all zeros */
+                       UNISTR2 *user_name,
+                       UNISTR2 *full_name,
+                       UNISTR2 *home_dir,
+                       UNISTR2 *dir_drive,
+                       UNISTR2 *log_scr,
+                       UNISTR2 *prof_path,
+                       UNISTR2 *desc,
+                       UNISTR2 *wkstas,
+                       UNISTR2 *unk_str,
+                       UNISTR2 *mung_dial,
+                       uint32 user_rid,        /* 0x0000 0000 */
+                       uint32 group_rid,
+                       uint32 acb_info,
+                       uint32 unknown_3,
+                       uint16 logon_divs,
+                       LOGON_HRS * hrs,
+                       uint32 unknown_5,
+                       char newpass[516], uint32 unknown_6);
+void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time,        /* all zeros */
+                          NTTIME * logoff_time,        /* all zeros */
+                          NTTIME * kickoff_time,       /* all zeros */
+                          NTTIME * pass_last_set_time, /* all zeros */
+                          NTTIME * pass_can_change_time,       /* all zeros */
+                          NTTIME * pass_must_change_time,      /* all zeros */
+                          char *user_name,     /* NULL */
+                          char *full_name,
+                          char *home_dir, char *dir_drive, char *log_scr,
+                          char *prof_path, char *desc, char *wkstas,
+                          char *unk_str, char *mung_dial, uint32 user_rid,     /* 0x0000 0000 */
+                          uint32 group_rid, uint32 acb_info,
+                          uint32 unknown_3, uint16 logon_divs,
+                          LOGON_HRS * hrs, uint32 unknown_5,
+                          char newpass[516], uint32 unknown_6);
+void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
+                          NTTIME * logon_time,
+                          NTTIME * logoff_time,
+                          NTTIME * kickoff_time,
+                          NTTIME * pass_last_set_time,
+                          NTTIME * pass_can_change_time,
+                          NTTIME * pass_must_change_time,
+                          UNISTR2 *user_name,
+                          UNISTR2 *full_name,
+                          UNISTR2 *home_dir,
+                          UNISTR2 *dir_drive,
+                          UNISTR2 *log_scr,
+                          UNISTR2 *prof_path,
+                          UNISTR2 *desc,
+                          UNISTR2 *wkstas,
+                          UNISTR2 *unk_str,
+                          UNISTR2 *mung_dial,
+                          uchar lm_pwd[16],
+                          uchar nt_pwd[16],
+                          uint32 user_rid,
+                          uint32 group_rid,
+                          uint32 acb_info,
+                          uint32 unknown_3,
+                          uint16 logon_divs,
+                          LOGON_HRS * hrs,
+                          uint32 unknown_5, uint32 unknown_6);
+void init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw);
+uint32 make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
+                                   uint16 switch_value,
+                                   SAM_USER_INFO_21 * usr);
+void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, uchar * sess_key,
+                           uint16 switch_value, void *info);
+void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
+                               SAM_USERINFO_CTR * ctr, uint32 status);
+BOOL samr_io_r_query_userinfo(char *desc, SAMR_R_QUERY_USERINFO * r_u,
+                             prs_struct *ps, int depth);
+void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
+                             POLICY_HND *hnd,  unsigned char sess_key[16],
+                             uint16 switch_value, void *info);
+BOOL samr_io_q_set_userinfo(char *desc, SAMR_Q_SET_USERINFO * q_u,
+                           prs_struct *ps, int depth);
+void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, uint32 status);
+BOOL samr_io_r_set_userinfo(char *desc, SAMR_R_SET_USERINFO * r_u,
+                           prs_struct *ps, int depth);
+void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
+                              POLICY_HND *hnd, unsigned char sess_key[16],
+                              uint16 switch_value, SAM_USERINFO_CTR * ctr);
+BOOL samr_io_q_set_userinfo2(char *desc, SAMR_Q_SET_USERINFO2 * q_u,
+                            prs_struct *ps, int depth);
+void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, uint32 status);
+BOOL samr_io_r_set_userinfo2(char *desc, SAMR_R_SET_USERINFO2 * r_u,
+                            prs_struct *ps, int depth);
+void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
+                        char *srv_name, uint32 access_mask);
+BOOL samr_io_q_connect(char *desc, SAMR_Q_CONNECT * q_u,
+                      prs_struct *ps, int depth);
+BOOL samr_io_r_connect(char *desc, SAMR_R_CONNECT * r_u,
+                      prs_struct *ps, int depth);
+void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u);
+BOOL samr_io_q_connect_anon(char *desc, SAMR_Q_CONNECT_ANON * q_u,
+                           prs_struct *ps, int depth);
+BOOL samr_io_r_connect_anon(char *desc, SAMR_R_CONNECT_ANON * r_u,
+                           prs_struct *ps, int depth);
+void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
+                               char *srv_name);
+BOOL samr_io_q_get_dom_pwinfo(char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
+                             prs_struct *ps, int depth);
+BOOL samr_io_r_get_dom_pwinfo(char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
+                             prs_struct *ps, int depth);
+void init_enc_passwd(SAMR_ENC_PASSWD * pwd, char pass[512]);
+BOOL samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD * pwd,
+                       prs_struct *ps, int depth);
+void init_enc_hash(SAMR_ENC_HASH * hsh, uchar hash[16]);
+BOOL samr_io_enc_hash(char *desc, SAMR_ENC_HASH * hsh,
+                     prs_struct *ps, int depth);
+void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
+                               char *dest_host, char *user_name,
+                               char nt_newpass[516],
+                               uchar nt_oldhash[16],
+                               char lm_newpass[516],
+                               uchar lm_oldhash[16]);
+BOOL samr_io_q_chgpasswd_user(char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
+                             prs_struct *ps, int depth);
+void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, uint32 status);
+BOOL samr_io_r_chgpasswd_user(char *desc, SAMR_R_CHGPASSWD_USER * r_u,
+                             prs_struct *ps, int depth);
 
 /*The following definitions come from  rpc_parse/parse_sec.c  */
 
@@ -3234,8 +3391,6 @@ void init_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n,
                                uint32 preferred_len, ENUM_HND *hnd);
 BOOL srv_io_q_net_share_enum(char *desc, SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth);
 BOOL srv_io_r_net_share_enum(char *desc, SRV_R_NET_SHARE_ENUM *r_n, prs_struct *ps, int depth);
-void free_srv_q_net_share_get_info(SRV_Q_NET_SHARE_GET_INFO *q_n);
-void free_srv_r_net_share_get_info(SRV_R_NET_SHARE_GET_INFO *r_n);
 BOOL srv_io_q_net_share_get_info(char *desc, SRV_Q_NET_SHARE_GET_INFO *q_n, prs_struct *ps, int depth);
 BOOL srv_io_r_net_share_get_info(char *desc, SRV_R_NET_SHARE_GET_INFO *r_n, prs_struct *ps, int depth);
 void init_srv_sess_info0_str(SESS_INFO_0_STR *ss0, char *name);
@@ -3276,6 +3431,7 @@ void init_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n,
                                ENUM_HND *hnd);
 BOOL srv_io_q_net_file_enum(char *desc, SRV_Q_NET_FILE_ENUM *q_n, prs_struct *ps, int depth);
 BOOL srv_io_r_net_file_enum(char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth);
+void init_srv_info_100(SRV_INFO_100 *sv100, uint32 platform_id, char *name);
 void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, char *name,
                                uint32 ver_major, uint32 ver_minor,
                                uint32 srv_type, char *comment);
@@ -3324,28 +3480,18 @@ uint32 _dfs_get_info(pipes_struct *p, DFS_Q_DFS_GET_INFO *q_u, DFS_R_DFS_GET_INF
 
 /*The following definitions come from  rpc_server/srv_lsa.c  */
 
-#if OLD_NTDOMAIN
 BOOL api_ntlsa_rpc(pipes_struct *p);
-#endif
 
 /*The following definitions come from  rpc_server/srv_lsa_hnd.c  */
 
-#if OLD_NTDOMAIN
-void create_policy_handle(POLICY_HND *hnd, uint32 *hnd_low, uint32 *hnd_high);
-void init_lsa_policy_hnd(void);
-BOOL open_lsa_policy_hnd(POLICY_HND *hnd);
-int find_lsa_policy_by_hnd(POLICY_HND *hnd);
-BOOL set_lsa_policy_samr_pol_status(POLICY_HND *hnd, uint32 pol_status);
-BOOL set_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid);
-BOOL get_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid);
-uint32 get_lsa_policy_samr_rid(POLICY_HND *hnd);
-BOOL set_lsa_policy_reg_name(POLICY_HND *hnd, fstring name);
-BOOL close_lsa_policy_hnd(POLICY_HND *hnd);
-#endif
+void init_pipe_handles(pipes_struct *p);
+BOOL create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *), void *data_ptr);
+BOOL find_policy_by_hnd(pipes_struct *p, POLICY_HND *hnd, void **data_p);
+BOOL close_policy_hnd(pipes_struct *p, POLICY_HND *hnd);
+void close_policy_by_pipe(pipes_struct *p);
 
 /*The following definitions come from  rpc_server/srv_lsa_nt.c  */
 
-#if OLD_NTDOMAIN
 uint32 _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2 *r_u);
 uint32 _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL *r_u);
 uint32 _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_ENUM_TRUST_DOM *r_u);
@@ -3354,17 +3500,23 @@ uint32 _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_SI
 uint32 _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_NAMES *r_u);
 uint32 _lsa_close(pipes_struct *p, LSA_Q_CLOSE *q_u, LSA_R_CLOSE *r_u);
 uint32 _lsa_open_secret(pipes_struct *p, LSA_Q_OPEN_SECRET *q_u, LSA_R_OPEN_SECRET *r_u);
-#endif
 
 /*The following definitions come from  rpc_server/srv_netlog.c  */
 
-#if OLD_NTDOMAIN
 BOOL api_netlog_rpc(pipes_struct *p);
-#endif
+
+/*The following definitions come from  rpc_server/srv_netlog_nt.c  */
+
+uint32 _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_CTRL2 *r_u);
+uint32 _net_trust_dom_list(pipes_struct *p, NET_Q_TRUST_DOM_LIST *q_u, NET_R_TRUST_DOM_LIST *r_u);
+uint32 _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u);
+uint32 _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u);
+uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_u);
+uint32 _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF *r_u);
+uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_u);
 
 /*The following definitions come from  rpc_server/srv_pipe.c  */
 
-#if OLD_NTDOMAIN
 BOOL create_next_pdu(pipes_struct *p);
 BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *rpc_in_p);
 BOOL setup_fault_pdu(pipes_struct *p);
@@ -3375,16 +3527,17 @@ BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in);
 BOOL api_pipe_request(pipes_struct *p);
 BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, 
                struct api_struct *api_rpc_cmds);
-#endif
 
 /*The following definitions come from  rpc_server/srv_pipe_hnd.c  */
 
-#if OLD_NTDOMAIN
+pipes_struct *get_first_pipe(void);
+pipes_struct *get_next_pipe(pipes_struct *p);
 void set_pipe_handle_offset(int max_open_files);
 void reset_chain_p(void);
 void init_rpc_pipe_hnd(void);
 pipes_struct *open_rpc_pipe_p(char *pipe_name, 
                              connection_struct *conn, uint16 vuid);
+void free_pipe_context(pipes_struct *p);
 ssize_t write_to_pipe(pipes_struct *p, char *data, size_t n);
 ssize_t read_from_pipe(pipes_struct *p, char *data, size_t n);
 BOOL wait_rpc_pipe_hnd_state(pipes_struct *p, uint16 priority);
@@ -3392,39 +3545,72 @@ BOOL set_rpc_pipe_hnd_state(pipes_struct *p, uint16 device_state);
 BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn);
 pipes_struct *get_rpc_pipe_p(char *buf, int where);
 pipes_struct *get_rpc_pipe(int pnum);
-#endif
 
 /*The following definitions come from  rpc_server/srv_reg.c  */
 
-#if OLD_NTDOMAIN
 BOOL api_reg_rpc(pipes_struct *p);
-#endif
 
 /*The following definitions come from  rpc_server/srv_reg_nt.c  */
 
-#if OLD_NTDOMAIN
 uint32 _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u);
 uint32 _reg_open(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u);
 uint32 _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY *r_u);
 uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u);
-#endif
 
 /*The following definitions come from  rpc_server/srv_samr.c  */
 
-#if OLD_NTDOMAIN
 BOOL api_samr_rpc(pipes_struct *p);
-#endif
+
+/*The following definitions come from  rpc_server/srv_samr_nt.c  */
+
+uint32 _samr_close_hnd(pipes_struct *p, SAMR_Q_CLOSE_HND *q_u, SAMR_R_CLOSE_HND *r_u);
+uint32 _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN_DOMAIN *r_u);
+uint32 _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, SAMR_R_GET_USRDOM_PWINFO *r_u);
+uint32 _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_QUERY_SEC_OBJ *r_u);
+uint32 _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, SAMR_R_ENUM_DOM_USERS *r_u);
+uint32 _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAMR_R_ENUM_DOM_GROUPS *r_u);
+uint32 _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, SAMR_R_ENUM_DOM_ALIASES *r_u);
+uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_QUERY_DISPINFO *r_u);
+uint32 _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAMR_R_QUERY_ALIASINFO *r_u);
+uint32 _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOKUP_NAMES *r_u);
+uint32 _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_R_CHGPASSWD_USER *r_u);
+uint32 _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP_RIDS *r_u);
+uint32 _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USER *r_u);
+uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_QUERY_USERINFO *r_u);
+uint32 _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, SAMR_R_QUERY_USERGROUPS *r_u);
+uint32 _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR_R_QUERY_DOMAIN_INFO *r_u);
+uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREATE_USER *r_u);
+uint32 _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CONNECT_ANON *r_u);
+uint32 _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u);
+uint32 _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_LOOKUP_DOMAIN *r_u);
+uint32 _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_ENUM_DOMAINS *r_u);
+uint32 _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_ALIAS *r_u);
+uint32 _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_USERINFO *r_u);
+uint32 _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SET_USERINFO2 *r_u);
+uint32 _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, SAMR_R_QUERY_USERALIASES *r_u);
+uint32 _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_R_QUERY_ALIASMEM *r_u);
+uint32 _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_R_QUERY_GROUPMEM *r_u);
+uint32 _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_ADD_ALIASMEM *r_u);
+uint32 _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DEL_ALIASMEM *r_u);
+uint32 _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_ADD_GROUPMEM *r_u);
+uint32 _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DEL_GROUPMEM *r_u);
+uint32 _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAMR_R_DELETE_DOM_USER *r_u );
+uint32 _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, SAMR_R_DELETE_DOM_GROUP *r_u);
+uint32 _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, SAMR_R_DELETE_DOM_ALIAS *r_u);
+uint32 _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, SAMR_R_CREATE_DOM_GROUP *r_u);
+uint32 _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, SAMR_R_CREATE_DOM_ALIAS *r_u);
+uint32 _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAMR_R_QUERY_GROUPINFO *r_u);
+uint32 _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_SET_GROUPINFO *r_u);
+uint32 _samr_get_dom_pwinfo(pipes_struct *p, SAMR_Q_GET_DOM_PWINFO *q_u, SAMR_R_GET_DOM_PWINFO *r_u);
+uint32 _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_GROUP *r_u);
+uint32 _samr_unknown_2d(pipes_struct *p, SAMR_Q_UNKNOWN_2D *q_u, SAMR_R_UNKNOWN_2D *r_u);
 
 /*The following definitions come from  rpc_server/srv_spoolss.c  */
 
-#if OLD_NTDOMAIN
 BOOL api_spoolss_rpc(pipes_struct *p);
-#endif
 
 /*The following definitions come from  rpc_server/srv_spoolss_nt.c  */
 
-#if OLD_NTDOMAIN
-void init_printer_hnd(void);
 void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len);
 uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, SPOOL_R_OPEN_PRINTER_EX *r_u);
 BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode,
@@ -3466,17 +3652,13 @@ uint32 _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS
 uint32 _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u);
 uint32 _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_u, SPOOL_R_ENUMPRINTMONITORS *r_u);
 uint32 _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_u);
-#endif
 
 /*The following definitions come from  rpc_server/srv_srvsvc.c  */
 
-#if OLD_NTDOMAIN
 BOOL api_srvsvc_rpc(pipes_struct *p);
-#endif
 
 /*The following definitions come from  rpc_server/srv_srvsvc_nt.c  */
 
-#if OLD_NTDOMAIN
 uint32 _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R_NET_SRV_GET_INFO *r_u);
 uint32 _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u);
 uint32 _srv_net_conn_enum(pipes_struct *p, SRV_Q_NET_CONN_ENUM *q_u, SRV_R_NET_CONN_ENUM *r_u);
@@ -3484,46 +3666,51 @@ uint32 _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_S
 uint32 _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u);
 uint32 _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, SRV_R_NET_SHARE_GET_INFO *r_u);
 uint32 _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET_REMOTE_TOD *r_u);
-#endif
 
 /*The following definitions come from  rpc_server/srv_util.c  */
 
-#if OLD_NTDOMAIN
-int make_dom_gids(char *gids_str, DOM_GID **ppgids);
+int make_dom_gids(TALLOC_CTX *ctx, char *gids_str, DOM_GID **ppgids);
 void get_domain_user_groups(char *domain_groups, char *user);
-uint32 lookup_group_name(uint32 rid, char *group_name, uint32 *type);
-uint32 lookup_alias_name(uint32 rid, char *alias_name, uint32 *type);
-uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type);
-uint32 lookup_group_rid(char *group_name, uint32 *rid);
-uint32 lookup_alias_rid(char *alias_name, uint32 *rid);
-uint32 lookup_user_rid(char *user_name, uint32 *rid);
-#endif
+uint32 local_lookup_group_name(uint32 rid, char *group_name, uint32 *type);
+uint32 local_lookup_alias_name(uint32 rid, char *alias_name, uint32 *type);
+uint32 local_lookup_user_name(uint32 rid, char *user_name, uint32 *type);
+uint32 local_lookup_group_rid(char *group_name, uint32 *rid);
+uint32 local_lookup_alias_rid(char *alias_name, uint32 *rid);
+uint32 local_lookup_user_rid(char *user_name, uint32 *rid);
 
 /*The following definitions come from  rpc_server/srv_wkssvc.c  */
 
-#if OLD_NTDOMAIN
 BOOL api_wkssvc_rpc(pipes_struct *p);
-#endif
 
 /*The following definitions come from  rpc_server/srv_wkssvc_nt.c  */
 
-#if OLD_NTDOMAIN
 uint32 _wks_query_info(pipes_struct *p, WKS_Q_QUERY_INFO *q_u, WKS_R_QUERY_INFO *r_u);
-#endif
+
+/*The following definitions come from  rpcclient/cmd_lsarpc.c  */
+
+
+/*The following definitions come from  rpcclient/cmd_samr.c  */
+
+
+/*The following definitions come from  rpcclient/cmd_spoolss.c  */
+
+
+/*The following definitions come from  rpcclient/rpcclient.c  */
+
+void fetch_domain_sid(void);
+void init_rpcclient_creds(struct ntuser_creds *creds);
+void add_command_set(struct cmd_set *cmd_set);
 
 /*The following definitions come from  smbd/blocking.c  */
 
-#if OLD_NTDOMAIN
 BOOL push_blocking_lock_request( char *inbuf, int length, int lock_timeout, int lock_num);
 void remove_pending_lock_requests_by_fid(files_struct *fsp);
 void remove_pending_lock_requests_by_mid(int mid);
 BOOL blocking_locks_pending(void);
 void process_blocking_lock_queue(time_t t);
-#endif
 
 /*The following definitions come from  smbd/chgpasswd.c  */
 
-#if OLD_NTDOMAIN
 BOOL chgpasswd(char *name, char *oldpass, char *newpass, BOOL as_root);
 BOOL chgpasswd(char *name, char *oldpass, char *newpass, BOOL as_root);
 BOOL check_lanman_password(char *user, uchar * pass1,
@@ -3542,17 +3729,13 @@ BOOL change_oem_password(SAM_ACCOUNT *hnd, char *new_passwd,
                         BOOL override);
 BOOL check_plaintext_password(char *user, char *old_passwd,
                              int old_passwd_size, SAM_ACCOUNT **hnd);
-#endif
 
 /*The following definitions come from  smbd/close.c  */
 
-#if OLD_NTDOMAIN
 int close_file(files_struct *fsp, BOOL normal_close);
-#endif
 
 /*The following definitions come from  smbd/conn.c  */
 
-#if OLD_NTDOMAIN
 void conn_init(void);
 int conn_num_open(void);
 BOOL conn_snum_used(int snum);
@@ -3561,7 +3744,6 @@ connection_struct *conn_new(void);
 void conn_close_all(void);
 BOOL conn_idle_all(time_t t, int deadtime);
 void conn_free(connection_struct *conn);
-#endif
 
 /*The following definitions come from  smbd/connection.c  */
 
@@ -3576,7 +3758,6 @@ SMB_BIG_UINT sys_disk_free(char *path, BOOL small_query,
 
 /*The following definitions come from  smbd/dir.c  */
 
-#if OLD_NTDOMAIN
 void init_dptrs(void);
 char *dptr_path(int key);
 char *dptr_wcard(int key);
@@ -3602,29 +3783,23 @@ int TellDir(void *p);
 void DirCacheAdd( char *path, char *name, char *dname, int snum );
 char *DirCacheCheck( char *path, char *name, int snum );
 void DirCacheFlush(int snum);
-#endif
 
 /*The following definitions come from  smbd/dosmode.c  */
 
-#if OLD_NTDOMAIN
 mode_t unix_mode(connection_struct *conn,int dosmode,const char *fname);
 int dos_mode(connection_struct *conn,char *path,SMB_STRUCT_STAT *sbuf);
 int file_chmod(connection_struct *conn,char *fname,int dosmode,SMB_STRUCT_STAT *st);
 int file_utime(connection_struct *conn, char *fname, struct utimbuf *times);
 BOOL set_filetime(connection_struct *conn, char *fname, time_t mtime);
-#endif
 
 /*The following definitions come from  smbd/error.c  */
 
-#if OLD_NTDOMAIN
 int cached_error_packet(char *inbuf,char *outbuf,files_struct *fsp,int line);
 int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int line);
 int error_packet(char *inbuf,char *outbuf,int error_class,uint32 error_code,int line);
-#endif
 
 /*The following definitions come from  smbd/fileio.c  */
 
-#if OLD_NTDOMAIN
 SMB_OFF_T seek_file(files_struct *fsp,SMB_OFF_T pos);
 BOOL read_from_write_cache(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n);
 ssize_t read_file(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n);
@@ -3633,19 +3808,15 @@ void delete_write_cache(files_struct *fsp);
 void set_filelen_write_cache(files_struct *fsp, SMB_OFF_T file_size);
 ssize_t flush_write_cache(files_struct *fsp, enum flush_reason_enum reason);
 void sync_file(connection_struct *conn, files_struct *fsp);
-#endif
 
 /*The following definitions come from  smbd/filename.c  */
 
-#if OLD_NTDOMAIN
 BOOL unix_convert(char *name,connection_struct *conn,char *saved_last_component, 
                   BOOL *bad_path, SMB_STRUCT_STAT *pst);
 BOOL check_name(char *name,connection_struct *conn);
-#endif
 
 /*The following definitions come from  smbd/files.c  */
 
-#if OLD_NTDOMAIN
 files_struct *file_new(void );
 void file_close_conn(connection_struct *conn);
 void file_init(void);
@@ -3661,24 +3832,19 @@ files_struct *file_fsp(char *buf, int where);
 void file_chain_reset(void);
 void file_chain_save(void);
 void file_chain_restore(void);
-#endif
 
 /*The following definitions come from  smbd/ipc.c  */
 
-#if OLD_NTDOMAIN
 void send_trans_reply(char *outbuf,
                                char *rparam, int rparam_len,
                                char *rdata, int rdata_len,
                                BOOL buffer_too_large);
 int reply_trans(connection_struct *conn, char *inbuf,char *outbuf, int size, int bufsize);
-#endif
 
 /*The following definitions come from  smbd/lanman.c  */
 
-#if OLD_NTDOMAIN
 int api_reply(connection_struct *conn,uint16 vuid,char *outbuf,char *data,char *params,
                     int tdscnt,int tpscnt,int mdrcnt,int mprcnt);
-#endif
 
 /*The following definitions come from  smbd/mangle.c  */
 
@@ -3691,7 +3857,6 @@ BOOL name_map_mangle(char *OutName, BOOL need83, BOOL cache83, int snum);
 
 /*The following definitions come from  smbd/message.c  */
 
-#if OLD_NTDOMAIN
 int reply_sends(connection_struct *conn,
                char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
 int reply_sendstrt(connection_struct *conn,
@@ -3700,15 +3865,12 @@ int reply_sendtxt(connection_struct *conn,
                  char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
 int reply_sendend(connection_struct *conn,
                  char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-#endif
 
 /*The following definitions come from  smbd/negprot.c  */
 
-#if OLD_NTDOMAIN
 int reply_negprot(connection_struct *conn, 
                  char *inbuf,char *outbuf, int dum_size, 
                  int dum_buffsize);
-#endif
 
 /*The following definitions come from  smbd/noquotas.c  */
 
@@ -3716,7 +3878,6 @@ BOOL disk_quotas(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT
 
 /*The following definitions come from  smbd/notify.c  */
 
-#if OLD_NTDOMAIN
 void remove_pending_change_notify_requests_by_fid(files_struct *fsp);
 void remove_pending_change_notify_requests_by_mid(int mid);
 void remove_pending_change_notify_requests_by_filename(files_struct *fsp);
@@ -3724,23 +3885,17 @@ int change_notify_timeout(void);
 BOOL process_pending_change_notify_queue(time_t t);
 BOOL change_notify_set(char *inbuf, files_struct *fsp, connection_struct *conn, uint32 flags);
 BOOL init_change_notify(void);
-#endif
 
 /*The following definitions come from  smbd/notify_hash.c  */
 
-#if OLD_NTDOMAIN
 struct cnotify_fns *hash_notify_init(void) ;
-#endif
 
 /*The following definitions come from  smbd/notify_kernel.c  */
 
-#if OLD_NTDOMAIN
 struct cnotify_fns *kernel_notify_init(void) ;
-#endif
 
 /*The following definitions come from  smbd/nttrans.c  */
 
-#if OLD_NTDOMAIN
 void fail_next_srvsvc_open(void);
 BOOL should_fail_next_srvsvc_open(const char *pipename);
 int reply_ntcreate_and_X(connection_struct *conn,
@@ -3751,11 +3906,9 @@ int reply_nttranss(connection_struct *conn,
                   char *inbuf,char *outbuf,int length,int bufsize);
 int reply_nttrans(connection_struct *conn,
                  char *inbuf,char *outbuf,int length,int bufsize);
-#endif
 
 /*The following definitions come from  smbd/open.c  */
 
-#if OLD_NTDOMAIN
 int fd_close(struct connection_struct *conn, files_struct *fsp);
 files_struct *open_file_shared(connection_struct *conn,char *fname, SMB_STRUCT_STAT *psbuf, 
                                int share_mode,int ofun, mode_t mode,int oplock_request, int *Access,int *action);
@@ -3764,11 +3917,9 @@ files_struct *open_file_stat(connection_struct *conn, char *fname,
 files_struct *open_directory(connection_struct *conn, char *fname,
                                                        SMB_STRUCT_STAT *psbuf, int smb_ofun, mode_t unixmode, int *action);
 BOOL check_file_sharing(connection_struct *conn,char *fname, BOOL rename_op);
-#endif
 
 /*The following definitions come from  smbd/oplock.c  */
 
-#if OLD_NTDOMAIN
 int32 get_number_of_exclusive_open_oplocks(void);
 BOOL receive_local_message(fd_set *fds, char *buffer, int buffer_len, int timeout);
 BOOL set_file_oplock(files_struct *fsp, int oplock_type);
@@ -3782,23 +3933,17 @@ BOOL request_oplock_break(share_mode_entry *share_entry,
 BOOL attempt_close_oplocked_file(files_struct *fsp);
 void release_level_2_oplocks_on_change(files_struct *fsp);
 BOOL init_oplocks(void);
-#endif
 
 /*The following definitions come from  smbd/oplock_irix.c  */
 
-#if OLD_NTDOMAIN
 struct kernel_oplocks *irix_init_kernel_oplocks(void) ;
-#endif
 
 /*The following definitions come from  smbd/oplock_linux.c  */
 
-#if OLD_NTDOMAIN
 struct kernel_oplocks *linux_init_kernel_oplocks(void) ;
-#endif
 
 /*The following definitions come from  smbd/password.c  */
 
-#if OLD_NTDOMAIN
 void generate_next_challenge(char *challenge);
 BOOL set_challenge(unsigned char *challenge);
 user_struct *get_valid_user_struct(uint16 vuid);
@@ -3828,31 +3973,25 @@ BOOL domain_client_validate( char *user, char *domain,
                              char *smb_apasswd, int smb_apasslen, 
                              char *smb_ntpasswd, int smb_ntpasslen,
                              BOOL *user_exists);
-#endif
 
 /*The following definitions come from  smbd/pipes.c  */
 
-#if OLD_NTDOMAIN
 int reply_open_pipe_and_X(connection_struct *conn,
                          char *inbuf,char *outbuf,int length,int bufsize);
 int reply_pipe_write(char *inbuf,char *outbuf,int length,int dum_bufsize);
 int reply_pipe_write_and_X(char *inbuf,char *outbuf,int length,int bufsize);
 int reply_pipe_read_and_X(char *inbuf,char *outbuf,int length,int bufsize);
 int reply_pipe_close(connection_struct *conn, char *inbuf,char *outbuf);
-#endif
 
 /*The following definitions come from  smbd/posix_acls.c  */
 
-#if OLD_NTDOMAIN
 size_t get_nt_acl(files_struct *fsp, SEC_DESC **ppdesc);
 BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd);
 int chmod_acl(char *name, mode_t mode);
 int fchmod_acl(int fd, mode_t mode);
-#endif
 
 /*The following definitions come from  smbd/process.c  */
 
-#if OLD_NTDOMAIN
 BOOL push_oplock_pending_smb_message(char *buf, int msg_len);
 BOOL receive_next_smb(char *inbuf, int bufsize, int timeout);
 void respond_to_all_remaining_local_messages(void);
@@ -3862,11 +4001,9 @@ void construct_reply_common(char *inbuf,char *outbuf);
 int chain_reply(char *inbuf,char *outbuf,int size,int bufsize);
 void check_reload(int t);
 void smbd_process(void);
-#endif
 
 /*The following definitions come from  smbd/reply.c  */
 
-#if OLD_NTDOMAIN
 int reply_special(char *inbuf,char *outbuf);
 int reply_tcon(connection_struct *conn,
               char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
@@ -3938,11 +4075,9 @@ int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int size,
 int reply_writebs(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
 int reply_setattrE(connection_struct *conn, char *inbuf,char *outbuf, int size, int dum_buffsize);
 int reply_getattrE(connection_struct *conn, char *inbuf,char *outbuf, int size, int dum_buffsize);
-#endif
 
 /*The following definitions come from  smbd/sec_ctx.c  */
 
-#if OLD_NTDOMAIN
 int get_current_groups(int *p_ngroups, gid_t **p_groups);
 void delete_nt_token(NT_USER_TOKEN **pptoken);
 NT_USER_TOKEN *dup_nt_token(NT_USER_TOKEN *ptoken);
@@ -3952,26 +4087,21 @@ void set_sec_ctx(uid_t uid, gid_t gid, int ngroups, gid_t *groups, NT_USER_TOKEN
 void set_root_sec_ctx(void);
 BOOL pop_sec_ctx(void);
 void init_sec_ctx(void);
-#endif
 
 /*The following definitions come from  smbd/server.c  */
 
-#if OLD_NTDOMAIN
 int smbd_server_fd(void);
 void smbd_set_server_fd(int fd);
 BOOL reload_services(BOOL test);
 void exit_server(char *reason);
-#endif
 
 /*The following definitions come from  smbd/service.c  */
 
-#if OLD_NTDOMAIN
 BOOL become_service(connection_struct *conn,BOOL do_chdir);
 int add_home_service(char *service, char *homedir);
 int find_service(char *service);
 connection_struct *make_connection(char *service,char *user,char *password, int pwlen, char *dev,uint16 vuid, int *ecode);
 void close_cnum(connection_struct *conn, uint16 vuid);
-#endif
 
 /*The following definitions come from  smbd/srvstr.c  */
 
@@ -4000,7 +4130,6 @@ BOOL reset_stat_cache( void );
 
 /*The following definitions come from  smbd/trans2.c  */
 
-#if OLD_NTDOMAIN
 int reply_findclose(connection_struct *conn,
                    char *inbuf,char *outbuf,int length,int bufsize);
 int reply_findnclose(connection_struct *conn, 
@@ -4009,11 +4138,9 @@ int reply_transs2(connection_struct *conn,
                  char *inbuf,char *outbuf,int length,int bufsize);
 int reply_trans2(connection_struct *conn,
                 char *inbuf,char *outbuf,int length,int bufsize);
-#endif
 
 /*The following definitions come from  smbd/uid.c  */
 
-#if OLD_NTDOMAIN
 BOOL become_guest(void);
 BOOL become_user(connection_struct *conn, uint16 vuid);
 BOOL unbecome_user(void );
@@ -4027,32 +4154,9 @@ DOM_SID *uid_to_sid(DOM_SID *psid, uid_t uid);
 DOM_SID *gid_to_sid(DOM_SID *psid, gid_t gid);
 BOOL sid_to_uid(DOM_SID *psid, uid_t *puid, enum SID_NAME_USE *sidtype);
 BOOL sid_to_gid(DOM_SID *psid, gid_t *pgid, enum SID_NAME_USE *sidtype);
-#endif
-
-/*The following definitions come from  smbd/vfs.c  */
-
-#if OLD_NTDOMAIN
-int vfs_init_default(connection_struct *conn);
-BOOL vfs_init_custom(connection_struct *conn);
-BOOL vfs_directory_exist(connection_struct *conn, char *dname, SMB_STRUCT_STAT *st);
-int vfs_mkdir(connection_struct *conn, char *fname, mode_t mode);
-char *vfs_getwd(connection_struct *conn, char *unix_path);
-BOOL vfs_file_exist(connection_struct *conn,char *fname,SMB_STRUCT_STAT *sbuf);
-ssize_t vfs_read_data(files_struct *fsp, char *buf, size_t byte_count);
-ssize_t vfs_write_data(files_struct *fsp,char *buffer,size_t N);
-int vfs_set_filelen(files_struct *fsp, SMB_OFF_T len);
-SMB_OFF_T vfs_transfer_file(int in_fd, files_struct *in_fsp,
-                           int out_fd, files_struct *out_fsp,
-                           SMB_OFF_T n, char *header, int headlen, int align);
-char *vfs_readdirname(connection_struct *conn, void *p);
-int vfs_ChDir(connection_struct *conn, char *path);
-char *vfs_GetWd(connection_struct *conn, char *path);
-BOOL reduce_name(connection_struct *conn, char *s,char *dir,BOOL widelinks);
-#endif
 
 /*The following definitions come from  smbd/vfs-wrap.c  */
 
-#if OLD_NTDOMAIN
 int vfswrap_dummy_connect(connection_struct *conn, char *service, char *user);
 void vfswrap_dummy_disconnect(connection_struct *conn);
 SMB_BIG_UINT vfswrap_disk_free(connection_struct *conn, char *path, BOOL small_query, SMB_BIG_UINT *bsize, 
@@ -4086,7 +4190,25 @@ BOOL vfswrap_fset_nt_acl(files_struct *fsp, int fd, uint32 security_info_sent, S
 BOOL vfswrap_set_nt_acl(files_struct *fsp, char *name, uint32 security_info_sent, SEC_DESC *psd);
 int vfswrap_chmod_acl(connection_struct *conn, char *name, mode_t mode);
 int vfswrap_fchmod_acl(files_struct *fsp, int fd, mode_t mode);
-#endif
+
+/*The following definitions come from  smbd/vfs.c  */
+
+int vfs_init_default(connection_struct *conn);
+BOOL vfs_init_custom(connection_struct *conn);
+BOOL vfs_directory_exist(connection_struct *conn, char *dname, SMB_STRUCT_STAT *st);
+int vfs_mkdir(connection_struct *conn, char *fname, mode_t mode);
+char *vfs_getwd(connection_struct *conn, char *unix_path);
+BOOL vfs_file_exist(connection_struct *conn,char *fname,SMB_STRUCT_STAT *sbuf);
+ssize_t vfs_read_data(files_struct *fsp, char *buf, size_t byte_count);
+ssize_t vfs_write_data(files_struct *fsp,char *buffer,size_t N);
+int vfs_set_filelen(files_struct *fsp, SMB_OFF_T len);
+SMB_OFF_T vfs_transfer_file(int in_fd, files_struct *in_fsp,
+                           int out_fd, files_struct *out_fsp,
+                           SMB_OFF_T n, char *header, int headlen, int align);
+char *vfs_readdirname(connection_struct *conn, void *p);
+int vfs_ChDir(connection_struct *conn, char *path);
+char *vfs_GetWd(connection_struct *conn, char *path);
+BOOL reduce_name(connection_struct *conn, char *s,char *dir,BOOL widelinks);
 
 /*The following definitions come from  smbwrapper/realcalls.c  */
 
index 210a352cf41a4a2ffe721e5e7ef81408916b6ddb..aa22b1996a8e60cf0a4267412d30dda88dd78f79 100644 (file)
@@ -126,7 +126,6 @@ BOOL do_reg_close(struct cli_state *cli, POLICY_HND *hnd);
 
 /*The following definitions come from  rpc_client/cli_samr.c  */
 
-#if OLD_NTDOMAIN
 BOOL get_samr_query_usergroups(struct cli_state *cli, 
                                POLICY_HND *pol_open_domain, uint32 user_rid,
                                uint32 *num_groups, DOM_GID *gid);
@@ -165,7 +164,6 @@ BOOL do_samr_query_usergroups(struct cli_state *cli,
 BOOL do_samr_query_userinfo(struct cli_state *cli, 
                                POLICY_HND *pol, uint16 switch_value, void* usr);
 BOOL do_samr_close(struct cli_state *cli, POLICY_HND *hnd);
-#endif
 
 /*The following definitions come from  rpc_client/cli_spoolss_notify.c  */
 
index 186f8f1115940a9af46f9554f3f217885f1eae84..ad7fa31365e844d2a4cac8b20dd9523fd5b5b944 100644 (file)
@@ -28,6 +28,7 @@
 
 enum SID_NAME_USE
 {
+       SID_NAME_USE_NONE = 0,/* NOTUSED */
        SID_NAME_USER    = 1, /* user */
        SID_NAME_DOM_GRP = 2, /* domain group */
        SID_NAME_DOMAIN  = 3, /* domain: don't know what this is */
index 3438e44abe25ec1820c859b08ec4d6df2d36a97f..15705a1b6cced59f8812c5d3c66af84922e23260 100644 (file)
 #ifndef _RPC_SAMR_H /* _RPC_SAMR_H */
 #define _RPC_SAMR_H 
 
+
 #include "rpc_misc.h"
 
+
 /*******************************************************************
  the following information comes from a QuickView on samsrv.dll,
  and gives an idea of exactly what is needed:
@@ -142,6 +144,8 @@ SamrTestPrivateFunctionsUser
 #define SAMR_CONNECT           0x39
 #define SAMR_SET_USERINFO      0x3A
 
+
+
 typedef struct logon_hours_info
 {
        uint32 len; /* normally 21 bytes */
@@ -213,8 +217,6 @@ typedef struct sam_user_info_23
 typedef struct sam_user_info_24
 {
        uint8 pass[516];
-       uint16 unk_0;
-
 } SAM_USER_INFO_24;
 
 
@@ -395,7 +397,7 @@ typedef struct q_samr_query_sec_obj_info
 typedef struct r_samr_query_sec_obj_info
 {
        uint32 ptr;
-       SEC_DESC_BUF buf;
+       SEC_DESC_BUF *buf;
 
        uint32 status;         /* return status */
 
@@ -537,15 +539,24 @@ typedef struct r_samr_lookup_domain_info
 
 } SAMR_R_LOOKUP_DOMAIN;
 
+
+/****************************************************************************
+SAMR_Q_OPEN_DOMAIN - unknown_0 values seen associated with SIDs:
+
+0x0000 03f1 and a specific   domain sid - S-1-5-21-44c01ca6-797e5c3d-33f83fd0
+0x0000 0200 and a specific   domain sid - S-1-5-21-44c01ca6-797e5c3d-33f83fd0
+*****************************************************************************/
+
 /* SAMR_Q_OPEN_DOMAIN */
 typedef struct q_samr_open_domain_info
 {
-       POLICY_HND connect_pol;   /* Policy handle */
-       uint32 access_mask;       /* Requested permissions */
-       DOM_SID2 dom_sid;         /* Domain SID */
+       POLICY_HND pol;   /* policy handle */
+       uint32 flags;               /* 0x2000 0000; 0x0000 0211; 0x0000 0280; 0x0000 0200 - flags? */
+       DOM_SID2 dom_sid;         /* domain SID */
 
 } SAMR_Q_OPEN_DOMAIN;
 
+
 /* SAMR_R_OPEN_DOMAIN - probably an open */
 typedef struct r_samr_open_domain_info
 {
@@ -1072,7 +1083,7 @@ typedef struct alias_info_ctr
 typedef struct r_samr_query_aliasinfo_info
 {
        uint32 ptr;        
-       ALIAS_INFO_CTR *ctr;
+       ALIAS_INFO_CTR ctr;
 
        uint32 status;
 
@@ -1083,7 +1094,7 @@ typedef struct r_samr_query_aliasinfo_info
 typedef struct q_samr_set_alias_info
 {
        POLICY_HND alias_pol;        /* policy handle */
-       ALIAS_INFO_CTR *ctr;
+       ALIAS_INFO_CTR ctr;
 
 } SAMR_Q_SET_ALIASINFO;
 
@@ -1449,7 +1460,7 @@ typedef struct q_samr_open_group_info
 /* SAMR_R_OPEN_GROUP - probably an open */
 typedef struct r_samr_open_group_info
 {
-       POLICY_HND group_pol;       /* policy handle */
+       POLICY_HND pol;       /* policy handle */
        uint32 status;         /* return status */
 
 } SAMR_R_OPEN_GROUP;
@@ -1585,6 +1596,7 @@ typedef struct r_samr_get_dom_pwinfo
 {
        uint16 unk_0;
        uint16 unk_1;
+       uint16 unk_2;
        uint32 status;
 
 } SAMR_R_GET_DOM_PWINFO;
index 96961cbd2fc463b70b15687d4759a18661d9b692..b18c70bf258a89663b0b72ccda1fe2aac9a0615f 100644 (file)
@@ -470,6 +470,16 @@ typedef struct r_net_file_enum_info
 
 } SRV_R_NET_FILE_ENUM;
 
+/* SRV_INFO_100 */
+typedef struct srv_info_100_info
+{
+       uint32 platform_id;     /* 0x500 */
+       uint32 ptr_name;        /* pointer to server name */
+
+       UNISTR2 uni_name;       /* server name "server" */
+
+} SRV_INFO_100;
+
 /* SRV_INFO_101 */
 typedef struct srv_info_101_info
 {
@@ -518,6 +528,7 @@ typedef struct srv_info_ctr_info
     {
                SRV_INFO_102 sv102; /* server info level 102 */
                SRV_INFO_101 sv101; /* server info level 101 */
+               SRV_INFO_100 sv100; /* server info level 100 */
 
     } srv;
 
index 1813d63ff77892ae6d2f87b570605177a6c1c35f..7625f529095e9ee04549862a230eeb07b0677a70 100644 (file)
@@ -50,6 +50,21 @@ struct bitmap *bitmap_allocate(int n)
        return bm;
 }
 
+/****************************************************************************
+free a bitmap.
+****************************************************************************/
+
+void bitmap_free(struct bitmap *bm)
+{
+       if (!bm)
+               return;
+
+       if(bm->b)
+               free(bm->b);
+
+       free(bm);
+}
+
 /****************************************************************************
 set a bit in a bitmap
 ****************************************************************************/
index 7fedc282ba9fa5c92ef801c2e65238f3d36195d0..4a3d7090e314df7cd44b994c50c5327d97abfbba 100644 (file)
@@ -19,9 +19,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 */
-
 #include "includes.h"
-
 #define CTRLZ 26
 extern int DEBUGLEVEL;
 
index 2ba35c00dbba87552965a5ff2485973ad112d8e4..27fa80ca3f82a5a3ad34e34a5299238d49e4a06a 100644 (file)
@@ -234,13 +234,13 @@ void debug_message(int msg_type, pid_t src, void *buf, size_t len)
        /* Set the new DEBUGLEVEL_CLASS array from the pased array */
        memcpy(DEBUGLEVEL_CLASS, buf, sizeof(DEBUGLEVEL_CLASS));
        
-       DEBUG(3,("INFO: Debug class %s level = %d   (pid %d from pid %d)\n",
+       DEBUG(1,("INFO: Debug class %s level = %d   (pid %d from pid %d)\n",
                        classname_table[DBGC_ALL],
                        DEBUGLEVEL_CLASS[DBGC_ALL], getpid(), (int)src));
 
        for (i=1; i<DBGC_LAST; i++) {
                if (DEBUGLEVEL_CLASS[i])
-                        DEBUGADD(3,("INFO: Debug class %s level = %d\n", 
+                        DEBUGADD(1,("INFO: Debug class %s level = %d\n", 
                                                classname_table[i], DEBUGLEVEL_CLASS[i]));
        }
 }
@@ -263,6 +263,11 @@ void setup_logging(char *pname, BOOL interactive)
 {
        message_register(MSG_DEBUG, debug_message);
 
+       /* reset to allow multiple setup calls, going from interactive to
+          non-interactive */
+       stdout_logging = False;
+       dbf = NULL;
+
        if (interactive) {
                stdout_logging = True;
                dbf = stdout;
index 19496bd426b121df9b25a29c3cb37fea610ccbda..ab02d1253bf77331b97c0566f0af1dd5d4e5e28a 100644 (file)
@@ -78,10 +78,7 @@ return current debug level
 ****************************************************************************/
 void debuglevel_message(int msg_type, pid_t src, void *buf, size_t len)
 {
-        int level;
-       
        DEBUG(1,("INFO: Received REQ_DEBUGLEVEL message from PID %d\n",src));
-        level = DEBUGLEVEL;
        message_send_pid(src, MSG_DEBUGLEVEL, DEBUGLEVEL_CLASS, sizeof(DEBUGLEVEL_CLASS), True);
 }
 
index 90fac637b3bef5eb286212edd8213d19067eee31..3451b6ec591d32e07a341f17d3b8f8aa7e21ef3d 100644 (file)
@@ -1,5 +1,3 @@
-#define OLD_NTDOMAIN 1
-
 /* 
    Unix SMB/Netbios implementation.
    Version 1.9.
@@ -327,6 +325,3 @@ void msrpc_net_use_enum(uint32 *num_cons, struct use_info ***use)
                add_use_info_to_array(num_cons, use, &item);
        }
 }
-
-
-#undef OLD_NTDOMAIN
index ed7113c8652d28be9a79af91af53dcba08977b2f..be81b4aa120edf6d5a78b00e34fa07b1e70a9c7e 100644 (file)
@@ -78,7 +78,6 @@ va_dcl
        char *format;
 #endif
        va_list ap;  
-       int ret;
        pstring str;
 
 #ifdef HAVE_STDARG_H
@@ -90,7 +89,7 @@ va_dcl
 #endif
        str[0] = 0;
 
-       ret = vslprintf(str,sizeof(str),format,ap);
+       vslprintf(str,sizeof(str),format,ap);
        va_end(ap);
        return write(fd, str, strlen(str));
 }
index 8ad2cfd713f8cda8b5cd3bcf62c79e569aa15f92..3811d81866fd1c4fafbcef07504224e4a5a358e7 100644 (file)
@@ -359,7 +359,7 @@ void set_message_bcc(char *buf,int num_bytes)
 ********************************************************************/
 void set_message_end(void *outbuf,void *end_ptr)
 {
-       set_message_bcc(outbuf,PTR_DIFF(end_ptr,smb_buf(outbuf)));
+       set_message_bcc((char *)outbuf,PTR_DIFF(end_ptr,smb_buf((char *)outbuf)));
 }
 
 /*******************************************************************
index d4540b15c5d0137f58134d47a922d08c5870dc7f..cf11110bd3230bf3435c2b687a9e7b11b03ec039 100644 (file)
@@ -1,4 +1,3 @@
-#define NEW_NTDOMAIN 1
 /* 
    Unix SMB/Netbios implementation.
    Version 2.2
@@ -519,5 +518,3 @@ uint32 cli_samr_query_groupmem(struct cli_state *cli, POLICY_HND *group_pol,
 
        return result;
 }
-
-#undef NEW_NTDOMAIN
index 5c3dae02c02bbda2f696ef7591db27feffc6b7da..175ab5c9b0a62b2ce78207080420db5fc21625df 100644 (file)
@@ -118,13 +118,11 @@ delete a record if it is for a dead process
 static int delete_fn(TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state)
 {
        struct lock_struct *locks;
-       struct lock_key *key;
        int count, i;
 
        tdb_chainlock(tdb, kbuf);
 
        locks = (struct lock_struct *)dbuf.dptr;
-       key = (struct lock_key *)kbuf.dptr;
 
        count = dbuf.dsize / sizeof(*locks);
        for (i=0; i<count; i++) {
index b3601e8752d0f096e8094be5f5add133b47369bf..118d59cc10c1115b9f5e3bb19326d058b8059c40 100644 (file)
@@ -396,7 +396,6 @@ BOOL set_share_mode(files_struct *fsp, uint16 port, uint16 op_type)
 {
        TDB_DATA dbuf;
        struct locking_data *data;
-       share_mode_entry *shares;
        char *p=NULL;
        int size;
                
@@ -410,12 +409,11 @@ BOOL set_share_mode(files_struct *fsp, uint16 port, uint16 op_type)
                pstrcat(fname, "/");
                pstrcat(fname, fsp->fsp_name);
 
-               size = sizeof(*data) + sizeof(*shares) + strlen(fname) + 1;
+               size = sizeof(*data) + sizeof(share_mode_entry) + strlen(fname) + 1;
                p = (char *)malloc(size);
                data = (struct locking_data *)p;
-               shares = (share_mode_entry *)(p + sizeof(*data));
                data->num_share_mode_entries = 1;
-               pstrcpy(p + sizeof(*data) + sizeof(*shares), fname);
+               pstrcpy(p + sizeof(*data) + sizeof(share_mode_entry), fname);
                fill_share_mode(p + sizeof(*data), fsp, port, op_type);
                dbuf.dptr = p;
                dbuf.dsize = size;
@@ -426,14 +424,13 @@ BOOL set_share_mode(files_struct *fsp, uint16 port, uint16 op_type)
 
        /* we're adding to an existing entry - this is a bit fiddly */
        data = (struct locking_data *)dbuf.dptr;
-       shares = (share_mode_entry *)(dbuf.dptr + sizeof(*data));
 
        data->num_share_mode_entries++;
-       size = dbuf.dsize + sizeof(*shares);
+       size = dbuf.dsize + sizeof(share_mode_entry);
        p = malloc(size);
        memcpy(p, dbuf.dptr, sizeof(*data));
        fill_share_mode(p + sizeof(*data), fsp, port, op_type);
-       memcpy(p + sizeof(*data) + sizeof(*shares), dbuf.dptr + sizeof(*data),
+       memcpy(p + sizeof(*data) + sizeof(share_mode_entry), dbuf.dptr + sizeof(*data),
               dbuf.dsize - sizeof(*data));
        free(dbuf.dptr);
        dbuf.dptr = p;
index 428dd004eee8c5db5ac1a79a0abdd6f6388efa8d..949f4b0498cbfd66111ad34ccca75c0cd1678186 100644 (file)
@@ -1687,8 +1687,3 @@ BOOL pdb_set_lanman_passwd (SAM_ACCOUNT *sampass, BYTE *pwd)
 
        return True;
 }
-
-
-
-
-
index 275ffa21edc66b1786faeb86fc4006b6e4f3c47b..c4fc3377c3f703ca443a66d2731fb316cce97e66 100644 (file)
@@ -48,9 +48,9 @@ static void add_auto_printers(void)
        printers = lp_servicenumber(PRINTERS_NAME);
 
        if (printers < 0) {
-               free(str);
-               return;
-       }
+        free(str);
+        return;
+    }
        
        for (p=strtok(str,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) {
                if (lp_servicenumber(p) >= 0) continue;
@@ -60,7 +60,7 @@ static void add_auto_printers(void)
                }
        }
 
-       free(str);
+    free(str);
 }
 
 /***************************************************************************
index e491d9a6b9933c114f988acc10b162c4c6a8ab08..f5c4a234ee21d3daf18650e87cf8457dfefae634 100644 (file)
@@ -1,4 +1,3 @@
-#define OLD_NTDOMAIN 1
 /*
  *  Unix SMB/Netbios implementation.
  *  Version 1.9.
@@ -1089,7 +1088,6 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
        struct passwd *pass;
        int ecode;
        int ver = 0;
-       int outsize = 0;
        int i;
 
        *perr = 0;
@@ -1175,7 +1173,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
                slprintf(new_name, sizeof(new_name), "%s/%s", architecture, driver->driverpath);        
                slprintf(old_name, sizeof(old_name), "%s/%s", new_dir, driver->driverpath);     
                if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
-                       if ((outsize = rename_internals(conn, inbuf, outbuf, new_name, old_name, True)) != 0) {
+                       if (rename_internals(conn, inbuf, outbuf, new_name, old_name, True) != 0) {
                                DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
                                                new_name, old_name));
                                *perr = (uint32)SVAL(outbuf,smb_err);
@@ -1192,7 +1190,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
                        slprintf(new_name, sizeof(new_name), "%s/%s", architecture, driver->datafile);  
                        slprintf(old_name, sizeof(old_name), "%s/%s", new_dir, driver->datafile);       
                        if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
-                               if ((outsize = rename_internals(conn, inbuf, outbuf, new_name, old_name, True)) != 0) {
+                               if (rename_internals(conn, inbuf, outbuf, new_name, old_name, True) != 0) {
                                        DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
                                                        new_name, old_name));
                                        *perr = (uint32)SVAL(outbuf,smb_err);
@@ -1211,7 +1209,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
                        slprintf(new_name, sizeof(new_name), "%s/%s", architecture, driver->configfile);        
                        slprintf(old_name, sizeof(old_name), "%s/%s", new_dir, driver->configfile);     
                        if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
-                               if ((outsize = rename_internals(conn, inbuf, outbuf, new_name, old_name, True)) != 0) {
+                               if (rename_internals(conn, inbuf, outbuf, new_name, old_name, True) != 0) {
                                        DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
                                                        new_name, old_name));
                                        *perr = (uint32)SVAL(outbuf,smb_err);
@@ -1231,7 +1229,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
                        slprintf(new_name, sizeof(new_name), "%s/%s", architecture, driver->helpfile);  
                        slprintf(old_name, sizeof(old_name), "%s/%s", new_dir, driver->helpfile);       
                        if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
-                               if ((outsize = rename_internals(conn, inbuf, outbuf, new_name, old_name, True)) != 0) {
+                               if (rename_internals(conn, inbuf, outbuf, new_name, old_name, True) != 0) {
                                        DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
                                                        new_name, old_name));
                                        *perr = (uint32)SVAL(outbuf,smb_err);
@@ -1260,7 +1258,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
                                slprintf(new_name, sizeof(new_name), "%s/%s", architecture, driver->dependentfiles[i]); 
                                slprintf(old_name, sizeof(old_name), "%s/%s", new_dir, driver->dependentfiles[i]);      
                                if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
-                                       if ((outsize = rename_internals(conn, inbuf, outbuf, new_name, old_name, True)) != 0) {
+                                       if (rename_internals(conn, inbuf, outbuf, new_name, old_name, True) != 0) {
                                                DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
                                                                new_name, old_name));
                                                *perr = (uint32)SVAL(outbuf,smb_err);
@@ -3195,4 +3193,3 @@ uint32 printer_write_default_dev(int snum, const PRINTER_DEFAULT *printer_defaul
        free_a_printer(&printer, 2);
        return result;
 }
-#undef OLD_NTDOMAIN
index c87fb9754f285580b97f92f475b432b1edcc5581..efb97be91943b7271fa350556e9c17f09685aa57 100644 (file)
@@ -1,5 +1,3 @@
-#define OLD_NTDOMAIN 1
-
 /* 
    Unix SMB/Netbios implementation.
    Version 3.0
@@ -98,5 +96,3 @@ void print_fsp_end(files_struct *fsp, BOOL normal_close)
                string_free(&fsp->fsp_name);
        }
 }
-
-#undef OLD_NTDOMAIN
index e771e936002c5ecfe025ed9af910924f562aba38..241135f744616e7d2ffb6debbf74d9fcd2d8fa6b 100644 (file)
@@ -1,4 +1,3 @@
-#define OLD_NTDOMAIN 1
 /* 
    Unix SMB/Netbios implementation.
    Version 3.0
@@ -792,14 +791,12 @@ BOOL print_job_resume(struct current_user *user, int jobid, int *errcode)
        char *printer_name;
        int snum, ret;
        fstring jobstr;
-       BOOL owner;
        
        if (!pjob || !user) return False;
 
        if (!pjob->spooled || pjob->sysjob == -1) return False;
 
        snum = print_job_snum(jobid);
-       owner = is_owner(user, jobid);
 
        if (!is_owner(user, jobid) &&
            !print_access_check(user, snum, JOB_ACCESS_ADMINISTER)) {
@@ -1401,4 +1398,3 @@ BOOL print_queue_purge(struct current_user *user, int snum, int *errcode)
 
        return True;
 }
-#undef OLD_NTDOMAIN
index eb9032f7ce7282cde1d049e7682982d4154784a7..a0e9ab6a0037d6d126944893223f924355d712e4 100644 (file)
@@ -1,4 +1,3 @@
-#define OLD_NTDOMAIN 1
 /* 
    Unix SMB/Netbios implementation.
    Version 1.9.
@@ -63,6 +62,9 @@ BOOL get_samr_query_usergroups(struct cli_state *cli,
        return do_samr_close(cli, &pol_open_user);
 }
 
+#if 0
+/* DOES NOT COMPILE WITH THE NEW SAMR PARSE CODE. JRA. */
+
 /****************************************************************************
 do a SAMR query user info
 ****************************************************************************/
@@ -97,6 +99,7 @@ BOOL get_samr_query_userinfo(struct cli_state *cli,
 
        return do_samr_close(cli, &pol_open_user);
 }
+#endif
 
 /****************************************************************************
 do a SAMR change user password command
@@ -156,6 +159,10 @@ BOOL do_samr_chgpasswd_user(struct cli_state *cli,
        return True;
 }
 
+#if 0 
+
+/* CURRENTLY THIS DOESN'T COMPILE AND IS NOT USED ANYWHERE. JRA. */
+
 /****************************************************************************
 do a SAMR unknown 0x38 command
 ****************************************************************************/
@@ -208,6 +215,7 @@ BOOL do_samr_unknown_38(struct cli_state *cli, char *srv_name)
 
        return True;
 }
+#endif
 
 /****************************************************************************
 do a SAMR unknown 0x8 command
@@ -266,6 +274,10 @@ BOOL do_samr_query_dom_info(struct cli_state *cli,
        return True;
 }
 
+#if 0
+
+/* CURRENTLY DOESN'T COMPILE WITH THE NEW SAMR PARSE CODE. JRA */
+
 /****************************************************************************
 do a SAMR enumerate users
 ****************************************************************************/
@@ -356,6 +368,7 @@ BOOL do_samr_enum_dom_users(struct cli_state *cli,
 
        return True;
 }
+#endif
 
 /****************************************************************************
 do a SAMR Connect
@@ -541,6 +554,10 @@ BOOL do_samr_open_domain(struct cli_state *cli,
        return True;
 }
 
+#if 0
+
+/* CURRENTLY DOES NOT COMPILE AND IS NOT USED ANYWHERE. JRA. */
+
 /****************************************************************************
 do a SAMR Query Unknown 12
 ****************************************************************************/
@@ -621,6 +638,7 @@ BOOL do_samr_query_unknown_12(struct cli_state *cli,
 
        return True;
 }
+#endif
 
 /****************************************************************************
 do a SAMR Query User Groups
@@ -684,6 +702,10 @@ BOOL do_samr_query_usergroups(struct cli_state *cli,
        return True;
 }
 
+#if 0
+
+/* CURRENTLY DOES NOT COMPILE WITH THE NEW SAMR PARSE CODE. JRA */
+
 /****************************************************************************
 do a SAMR Query User Info
 ****************************************************************************/
@@ -756,6 +778,8 @@ BOOL do_samr_query_userinfo(struct cli_state *cli,
        return True;
 }
 
+#endif
+
 /****************************************************************************
 do a SAMR Close
 ****************************************************************************/
@@ -820,5 +844,3 @@ BOOL do_samr_close(struct cli_state *cli, POLICY_HND *hnd)
 
        return True;
 }
-
-#undef OLD_NTDOMAIN
index e1d88ab5093d161a962bc3a578c8aeb2fa3b4e96..6bae2ae4a6b895a9412f6f6cb93a41fdee9f446d 100644 (file)
@@ -411,7 +411,7 @@ BOOL dfs_io_dfs_info_ctr(char* desc, DFS_INFO_CTR* ctr, uint32 num_entries, uint
                                return False;
                        if(!prs_uint32("ptr_comment", ps, depth, &ctr->dfs.info3[i].ptr_comment))
                                return False;
-                       if(!prs_uint32("state", ps, depth, &ctr->dfs.info3[i].state));
+                       if(!prs_uint32("state", ps, depth, &ctr->dfs.info3[i].state))
                                return False;
                        if(!prs_uint32("num_storages", ps, depth, &ctr->dfs.info3[i].num_storages))
                                return False;
index d86df0ee113e96ca2cd7cb8784c0066af9fadce3..98ef3fd0ee3232389b26bbec2e30a1991d51e8e3 100644 (file)
@@ -591,17 +591,16 @@ BOOL lsa_io_r_enum_trust_dom(char *desc, LSA_R_ENUM_TRUST_DOM *r_e,
 
                num_domains = r_e->num_domains2;
 
-               if (!(r_e->hdr_domain_name = (UNIHDR2 *)
-                     malloc(sizeof(UNIHDR2) * num_domains)))
-                       return False;
+               if (UNMARSHALLING(ps)) {
+                       if (!(r_e->hdr_domain_name = (UNIHDR2 *)prs_alloc_mem(ps,sizeof(UNIHDR2) * num_domains)))
+                               return False;
 
-               if (!(r_e->uni_domain_name = (UNISTR2 *)
-                     malloc(sizeof(UNISTR2) * num_domains)))
-                       return False;
+                       if (!(r_e->uni_domain_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2) * num_domains)))
+                               return False;
 
-               if (!(r_e->domain_sid = (DOM_SID2 *)
-                     malloc(sizeof(DOM_SID2) * num_domains)))
-                       return False;
+                       if (!(r_e->domain_sid = (DOM_SID2 *)prs_alloc_mem(ps,sizeof(DOM_SID2) * num_domains)))
+                               return False;
+               }
 
                for (i = 0; i < num_domains; i++) {
                        if(!smb_io_unihdr2 ("", &r_e->hdr_domain_name[i], ps, 
index bde8c01240e3d6a260a929b2893145aa9907e491..f1ff965df24d96a74cd4af6538ae7e89ff56d691 100644 (file)
@@ -627,7 +627,7 @@ BOOL net_io_r_srv_pwset(char *desc, NET_R_SRV_PWSET *r_s, prs_struct *ps, int de
  Init DOM_SID2 array from a string containing multiple sids
  *************************************************************************/
 
-static int init_dom_sid2s(char *sids_str, DOM_SID2 **ppsids)
+static int init_dom_sid2s(TALLOC_CTX *ctx, char *sids_str, DOM_SID2 **ppsids)
 {
        char *ptr;
        pstring s2;
@@ -647,7 +647,7 @@ static int init_dom_sid2s(char *sids_str, DOM_SID2 **ppsids)
                        ;
 
                /* Now allocate space for them. */
-               *ppsids = (DOM_SID2 *)malloc(count * sizeof(DOM_SID2));
+               *ppsids = (DOM_SID2 *)talloc_zero(ctx, count * sizeof(DOM_SID2));
                if (*ppsids == NULL)
                        return 0;
 
@@ -936,14 +936,22 @@ void init_sam_info(DOM_SAM_INFO *sam,
  Reads or writes a DOM_SAM_INFO structure.
 ********************************************************************/
 
-static BOOL net_io_id_info_ctr(char *desc, NET_ID_INFO_CTR *ctr, prs_struct *ps, int depth)
+static BOOL net_io_id_info_ctr(char *desc, NET_ID_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
 {
-       if (ctr == NULL)
-               return False;
+       NET_ID_INFO_CTR *ctr = *pp_ctr;
 
        prs_debug(ps, depth, desc, "smb_io_sam_info");
        depth++;
 
+       if (UNMARSHALLING(ps)) {
+               ctr = *pp_ctr = (NET_ID_INFO_CTR *)prs_alloc_mem(ps, sizeof(NET_ID_INFO_CTR));
+               if (ctr == NULL)
+                       return False;
+       }
+       
+       if (ctr == NULL)
+               return False;
+
        /* don't 4-byte align here! */
 
        if(!prs_uint16("switch_value ", ps, depth, &ctr->switch_value))
@@ -993,8 +1001,8 @@ static BOOL smb_io_sam_info(char *desc, DOM_SAM_INFO *sam, prs_struct *ps, int d
        if(!prs_uint16("logon_level  ", ps, depth, &sam->logon_level))
                return False;
 
-       if (sam->logon_level != 0 && sam->ctr != NULL) {
-               if(!net_io_id_info_ctr("logon_info", sam->ctr, ps, depth))
+       if (sam->logon_level != 0) {
+               if(!net_io_id_info_ctr("logon_info", &sam->ctr, ps, depth))
                        return False;
        }
 
@@ -1005,7 +1013,7 @@ static BOOL smb_io_sam_info(char *desc, DOM_SAM_INFO *sam, prs_struct *ps, int d
  Init
  *************************************************************************/
 
-void init_net_user_info3(NET_USER_INFO_3 *usr, SAM_ACCOUNT *sampw,
+void init_net_user_info3(TALLOC_CTX *ctx, NET_USER_INFO_3 *usr, SAM_ACCOUNT *sampw,
                         uint16 logon_count, uint16 bad_pw_count,
                         uint32 num_groups, DOM_GID *gids,
                         uint32 user_flgs, char *sess_key,
@@ -1090,7 +1098,7 @@ void init_net_user_info3(NET_USER_INFO_3 *usr, SAM_ACCOUNT *sampw,
 
        memset((char *)usr->padding, '\0', sizeof(usr->padding));
 
-       num_other_sids = init_dom_sid2s(other_sids, &usr->other_sids);
+       num_other_sids = init_dom_sid2s(ctx, other_sids, &usr->other_sids);
 
        usr->num_other_sids = num_other_sids;
        usr->buffer_other_sids = (num_other_sids != 0) ? 1 : 0; 
@@ -1105,7 +1113,7 @@ void init_net_user_info3(NET_USER_INFO_3 *usr, SAM_ACCOUNT *sampw,
        usr->num_groups2 = num_groups;
 
        if (num_groups > 0) {
-               usr->gids = (DOM_GID *)malloc(sizeof(DOM_GID) * num_groups);
+               usr->gids = (DOM_GID *)talloc_zero(ctx,sizeof(DOM_GID) * num_groups);
                if (usr->gids == NULL)
                        return;
                for (i = 0; i < num_groups; i++)
@@ -1119,16 +1127,6 @@ void init_net_user_info3(NET_USER_INFO_3 *usr, SAM_ACCOUNT *sampw,
        /* "other" sids are set up above */
 }
 
-/*******************************************************************
- Delete any memory allocated by init_user_info_3...
-********************************************************************/
-
-void free_user_info3(NET_USER_INFO_3 *usr)
-{
-       safe_free(usr->gids);
-       safe_free(usr->other_sids);
-}
-
 /*******************************************************************
  This code has been modified to cope with a NET_USER_INFO_2 - which is
  exactly the same as a NET_USER_INFO_3, minus the other sids parameters.
index 462c9ed19900b9e9693e8d8ce44ceb2905ae0888..5cfa84ff3dc92c3df855a55d9fec605fe13660a2 100644 (file)
@@ -1,11 +1,12 @@
-#define OLD_NTDOMAIN 1
 /* 
  *  Unix SMB/Netbios implementation.
  *  Version 1.9.
  *  RPC Pipe client / server routines
- *  Copyright (C) Andrew Tridgell              1992-1997,
- *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
- *  Copyright (C) Paul Ashton                       1997.
+ *  Copyright (C) Andrew Tridgell              1992-2000,
+ *  Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
+ *  Copyright (C) Paul Ashton                  1997-2000,
+ *  Copyright (C) Elrond                            2000,
+ *  Copyright (C) Jeremy Allison                    2001
  *  
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+
 #include "includes.h"
+#include "rpc_parse.h"
+#include "rpc_client.h"
+#include "nterr.h"
 
 extern int DEBUGLEVEL;
 
 /*******************************************************************
- Inits a SAMR_Q_CLOSE_HND structure.
+inits a SAMR_Q_CLOSE_HND structure.
 ********************************************************************/
 
-void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND *q_c, POLICY_HND *hnd)
+void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
 {
-       DEBUG(5,("init_samr_q_close_hnd\n"));
-
-       memcpy(&q_c->pol, hnd, sizeof(q_c->pol));
+       DEBUG(5, ("init_samr_q_close_hnd\n"));
+       
+       q_c->pol = *hnd;
 }
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_close_hnd(char *desc,  SAMR_Q_CLOSE_HND *q_u, prs_struct *ps, int depth)
+BOOL samr_io_q_close_hnd(char *desc, SAMR_Q_CLOSE_HND * q_u,
+                        prs_struct *ps, int depth)
 {
        if (q_u == NULL)
                return False;
@@ -52,19 +58,15 @@ BOOL samr_io_q_close_hnd(char *desc,  SAMR_Q_CLOSE_HND *q_u, prs_struct *ps, int
        if(!prs_align(ps))
                return False;
 
-       if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
-               return False;
-       if(!prs_align(ps))
-               return False;
-
-       return True;
+       return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
 }
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_close_hnd(char *desc,  SAMR_R_CLOSE_HND *r_u, prs_struct *ps, int depth)
+BOOL samr_io_r_close_hnd(char *desc, SAMR_R_CLOSE_HND * r_u,
+                        prs_struct *ps, int depth)
 {
        if (r_u == NULL)
                return False;
@@ -77,8 +79,6 @@ BOOL samr_io_r_close_hnd(char *desc,  SAMR_R_CLOSE_HND *r_u, prs_struct *ps, int
 
        if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
                return False;
-       if(!prs_align(ps))
-               return False;
 
        if(!prs_uint32("status", ps, depth, &r_u->status))
                return False;
@@ -86,74 +86,93 @@ BOOL samr_io_r_close_hnd(char *desc,  SAMR_R_CLOSE_HND *r_u, prs_struct *ps, int
        return True;
 }
 
-
 /*******************************************************************
- Reads or writes a structure.
+inits a SAMR_Q_LOOKUP_DOMAIN structure.
 ********************************************************************/
 
-void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, 
-                            POLICY_HND *connect_pol, 
-                            uint32 access_mask, DOM_SID *sid)
+void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
+                              POLICY_HND *pol, char *dom_name)
 {
-       DEBUG(5,("samr_init_q_open_domain\n"));
+       int len_name = strlen(dom_name);
 
-       q_u->pol = *connect_pol;
-       q_u->access_mask = access_mask;
-       init_dom_sid2(&q_u->dom_sid, sid);
+       DEBUG(5, ("init_samr_q_lookup_domain\n"));
+
+       q_u->connect_pol = *pol;
+
+       init_uni_hdr(&q_u->hdr_domain, len_name);
+       init_unistr2(&q_u->uni_domain, dom_name, len_name);
 }
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
-
-BOOL samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN *q_u, prs_struct *ps, int depth)
+BOOL samr_io_q_lookup_domain(char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
+                            prs_struct *ps, int depth)
 {
        if (q_u == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_q_open_domain");
+       prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
-               return False;
-       if(!prs_align(ps))
+       if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
                return False;
 
-       if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
+       if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
                return False;
 
-       if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
-               return False;
-       if(!prs_align(ps))
+       if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
                return False;
 
        return True;
 }
 
+/*******************************************************************
+inits a SAMR_R_LOOKUP_DOMAIN structure.
+********************************************************************/
+
+void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
+                              DOM_SID *dom_sid, uint32 status)
+{
+       DEBUG(5, ("init_samr_r_lookup_domain\n"));
+
+       r_u->status = status;
+       r_u->ptr_sid = 0;
+       if (status == 0x0) {
+               r_u->ptr_sid = 1;
+               init_dom_sid2(&r_u->dom_sid, dom_sid);
+       }
+}
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN *r_u, prs_struct *ps, int depth)
+BOOL samr_io_r_lookup_domain(char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
+                            prs_struct *ps, int depth)
 {
        if (r_u == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_r_open_domain");
+       prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
-               return False;
-       if(!prs_align(ps))
+       if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
                return False;
 
+       if (r_u->ptr_sid != 0) {
+               if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
+                       return False;
+               if(!prs_align(ps))
+                       return False;
+       }
+
        if(!prs_uint32("status", ps, depth, &r_u->status))
                return False;
 
@@ -161,34 +180,39 @@ BOOL samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN *r_u, prs_struct *ps,
 }
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-void init_samr_q_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, POLICY_HND *user_pol)
+void init_samr_q_unknown_2d(SAMR_Q_UNKNOWN_2D * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
 {
-       DEBUG(5,("samr_init_q_unknown_2c\n"));
+       DEBUG(5, ("samr_init_samr_q_unknown_2d\n"));
 
-       memcpy(&q_u->user_pol, user_pol, sizeof(q_u->user_pol));
+       q_u->dom_pol = *dom_pol;
+       init_dom_sid2(&q_u->sid, sid);
 }
 
-
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_unknown_2c(char *desc,  SAMR_Q_UNKNOWN_2C *q_u, prs_struct *ps, int depth)
+BOOL samr_io_q_unknown_2d(char *desc, SAMR_Q_UNKNOWN_2D * q_u,
+                         prs_struct *ps, int depth)
 {
        if (q_u == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_q_unknown_2c");
+       prs_debug(ps, depth, desc, "samr_io_q_unknown_2d");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
+       if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
+               return False;
+
+       if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
                return False;
+
        if(!prs_align(ps))
                return False;
 
@@ -196,282 +220,263 @@ BOOL samr_io_q_unknown_2c(char *desc,  SAMR_Q_UNKNOWN_2C *q_u, prs_struct *ps, i
 }
 
 /*******************************************************************
- Inits a structure.
-********************************************************************/
-
-void init_samr_r_unknown_2c(SAMR_R_UNKNOWN_2C *q_u, uint32 status)
-{
-       DEBUG(5,("samr_init_r_unknown_2c\n"));
-
-       q_u->unknown_0 = 0x00160000;
-       q_u->unknown_1 = 0x00000000;
-       q_u->status    = status;
-}
-
-
-/*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_unknown_2c(char *desc,  SAMR_R_UNKNOWN_2C *r_u, prs_struct *ps, int depth)
+BOOL samr_io_r_unknown_2d(char *desc, SAMR_R_UNKNOWN_2D * r_u,
+                         prs_struct *ps, int depth)
 {
        if (r_u == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_r_unknown_2c");
+       prs_debug(ps, depth, desc, "samr_io_r_unknown_2d");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!prs_uint32("unknown_0", ps, depth, &r_u->unknown_0))
-               return False;
-       if(!prs_uint32("unknown_1", ps, depth, &r_u->unknown_1))
-               return False;
-       if(!prs_uint32("status   ", ps, depth, &r_u->status))
+       if(!prs_uint32("status", ps, depth, &r_u->status))
                return False;
 
        return True;
 }
 
 /*******************************************************************
- Inits a SAMR_Q_UNKNOWN_3 structure.
+reads or writes a structure.
 ********************************************************************/
 
-void init_samr_q_unknown_3(SAMR_Q_UNKNOWN_3 *q_u,
-                               POLICY_HND *user_pol, uint16 switch_value)
+void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
+                            POLICY_HND *pol, uint32 flags,
+                            DOM_SID *sid)
 {
-       DEBUG(5,("samr_init_q_unknown_3\n"));
+       DEBUG(5, ("samr_init_samr_q_open_domain\n"));
 
-       memcpy(&q_u->user_pol, user_pol, sizeof(q_u->user_pol));
-       q_u->switch_value = switch_value;
+       q_u->pol = *pol;
+       q_u->flags = flags;
+       init_dom_sid2(&q_u->dom_sid, sid);
 }
 
-
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_unknown_3(char *desc,  SAMR_Q_UNKNOWN_3 *q_u, prs_struct *ps, int depth)
+BOOL samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
+                          prs_struct *ps, int depth)
 {
        if (q_u == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_q_unknown_3");
+       prs_debug(ps, depth, desc, "samr_io_q_open_domain");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
+       if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
                return False;
 
-       if(!prs_align(ps))
+       if(!prs_uint32("flags", ps, depth, &q_u->flags))
                return False;
 
-       if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
+       if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
+               return False;
+
+       return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+
+BOOL samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN * r_u,
+                          prs_struct *ps, int depth)
+{
+       if (r_u == NULL)
                return False;
+
+       prs_debug(ps, depth, desc, "samr_io_r_open_domain");
+       depth++;
+
        if(!prs_align(ps))
                return False;
 
+       if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
+               return False;
+
+       if(!prs_uint32("status", ps, depth, &r_u->status))
+               return False;
+
        return True;
 }
 
 /*******************************************************************
- Inits a SAMR_Q_QUERY_DOMAIN_INFO structure.
+reads or writes a structure.
 ********************************************************************/
 
-void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u,
-                               POLICY_HND *domain_pol, uint16 switch_value)
+void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
+                                  POLICY_HND *user_pol)
 {
-       DEBUG(5,("init_samr_q_query_dom_info\n"));
+       DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
 
-       memcpy(&q_u->domain_pol, domain_pol, sizeof(q_u->domain_pol));
-       q_u->switch_value = switch_value;
+       q_u->user_pol = *user_pol;
 }
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_query_dom_info(char *desc,  SAMR_Q_QUERY_DOMAIN_INFO *q_u, prs_struct *ps, int depth)
+BOOL samr_io_q_get_usrdom_pwinfo(char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
+                                prs_struct *ps, int depth)
 {
        if (q_u == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
+       prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
-               return False;
-       if(!prs_align(ps))
-               return False;
-
-       if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
-               return False;
-
-       return True;
+       return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
 }
 
 /*******************************************************************
-Inits a structure.
+ Init.
 ********************************************************************/
-BOOL init_unk_info1(SAM_UNK_INFO_1 *u_1)
-{
-       if (u_1 == NULL)
-               return False;
 
-       memset(u_1->padding, 0, sizeof(u_1->padding));  /* 12 bytes zeros */
-       u_1->unknown_1 = 0x80000000;
-       u_1->unknown_2 = 0x00000000;
+void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, uint32 status)
+{
+       DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
+       
+       r_u->unknown_0 = 0x0000;
+    r_u->unknown_1 = 0x0015;
+    r_u->unknown_2 = 0x00000000;
 
-       return True;
+       r_u->status = status;
 }
 
 /*******************************************************************
 reads or writes a structure.
 ********************************************************************/
-static BOOL sam_io_unk_info1(char *desc, SAM_UNK_INFO_1 *u_1, prs_struct *ps, int depth)
+
+BOOL samr_io_r_get_usrdom_pwinfo(char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
+                                prs_struct *ps, int depth)
 {
-       if (u_1 == NULL)
+       if (r_u == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "sam_io_unk_info1");
+       prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
        depth++;
 
-       if(!prs_uint8s(False, "padding", ps, depth, u_1->padding, sizeof(u_1->padding)))
+       if(!prs_align(ps))
                return False;
 
-       if(!prs_uint32("unknown_1", ps, depth, &u_1->unknown_1))        /* 0x8000 0000 */
+       if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0))
                return False;
-       if(!prs_uint32("unknown_2", ps, depth, &u_1->unknown_2))        /* 0x0000 0000 */
+       if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
                return False;
-
-       if(!prs_align(ps))
+       if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2))
+               return False;
+       if(!prs_uint32("status   ", ps, depth, &r_u->status))
                return False;
 
        return True;
 }
 
 /*******************************************************************
- Inits a structure.
+reads or writes a structure.
 ********************************************************************/
 
-void init_unk_info2(SAM_UNK_INFO_2 *u_2, char *domain, char *server)
+void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
+                              POLICY_HND *user_pol, uint32 sec_info)
 {
-       int len_domain = strlen(domain)+1;
-       int len_server = strlen(server)+1;
-
-       u_2->unknown_0 = 0x00000000;
-       u_2->unknown_1 = 0x80000000;
-       u_2->unknown_2 = 0x00000000;
-
-       u_2->ptr_0 = 1;
-       init_uni_hdr(&u_2->hdr_domain, len_domain);
-       init_uni_hdr(&u_2->hdr_server, len_server);
-
-       u_2->seq_num = 0x10000000;
-       u_2->unknown_3 = 0x00000000;
-       
-       u_2->unknown_4  = 0x00000001;
-       u_2->unknown_5  = 0x00000003;
-       u_2->unknown_6  = 0x00000001;
-       u_2->num_domain_usrs  = 0x00000008;
-       u_2->num_domain_grps = 0x00000003;
-       u_2->num_local_grps = 0x00000003;
-
-       memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
+       DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
 
-       init_unistr2(&u_2->uni_domain, domain, len_domain);
-       init_unistr2(&u_2->uni_server, server, len_server);
+       q_u->user_pol = *user_pol;
+       q_u->sec_info = sec_info;
 }
 
+
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL sam_io_unk_info2(char *desc, SAM_UNK_INFO_2 *u_2, prs_struct *ps, int depth)
+BOOL samr_io_q_query_sec_obj(char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
+                            prs_struct *ps, int depth)
 {
-       if (u_2 == NULL)
+       if (q_u == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "sam_io_unk_info2");
+       prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
        depth++;
 
-       if(!prs_uint32("unknown_0", ps, depth, &u_2->unknown_0)) /* 0x0000 0000 */
-               return False;
-       if(!prs_uint32("unknown_1", ps, depth, &u_2->unknown_1)) /* 0x8000 0000 */
-               return False;
-       if(!prs_uint32("unknown_2", ps, depth, &u_2->unknown_2)) /* 0x0000 0000 */
+       if(!prs_align(ps))
                return False;
 
-       if(!prs_uint32("ptr_0", ps, depth, &u_2->ptr_0))     /* pointer to unknown structure */
-               return False;
-       if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth)) /* domain name unicode header */
+       if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
                return False;
-       if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth)) /* server name unicode header */
+
+       if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
                return False;
 
-       /* put all the data in here, at the moment, including what the above
-          pointer is referring to
-        */
+       return True;
+}
 
-       if(!prs_uint32("seq_num ", ps, depth, &u_2->seq_num )) /* 0x0000 0099 or 0x1000 0000 */
-               return False;
-       if(!prs_uint32("unknown_3 ", ps, depth, &u_2->unknown_3 )) /* 0x0000 0000 */
-               return False;
-       
-       if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4 )) /* 0x0000 0001 */
-               return False;
-       if(!prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5 )) /* 0x0000 0003 */
-               return False;
-       if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6 )) /* 0x0000 0001 */
-               return False;
-       if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs )) /* 0x0000 0008 */
-               return False;
-       if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps)) /* 0x0000 0003 */
-               return False;
-       if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps)) /* 0x0000 0003 */
-               return False;
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
 
-       if(!prs_uint8s(False, "padding", ps, depth, u_2->padding, sizeof(u_2->padding))) /* 12 bytes zeros */
-               return False;
+void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
+                               POLICY_HND *domain_pol, uint16 switch_value)
+{
+       DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
+
+       q_u->domain_pol = *domain_pol;
+       q_u->switch_value = switch_value;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
 
-       if(!smb_io_unistr2( "uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth)) /* domain name unicode string */
+BOOL samr_io_q_query_dom_info(char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
+                             prs_struct *ps, int depth)
+{
+       if (q_u == NULL)
                return False;
+
+       prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
+       depth++;
+
        if(!prs_align(ps))
                return False;
 
-       if(!smb_io_unistr2( "uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth)) /* server name unicode string */
+       if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
                return False;
 
-       if(!prs_align(ps))
+       if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
                return False;
 
        return True;
 }
 
+
 /*******************************************************************
-Inits a structure.
+inits a structure.
 ********************************************************************/
-BOOL init_unk_info3(SAM_UNK_INFO_3 * u_3)
-{
-       if (u_3 == NULL)
-               return False;
 
+void init_unk_info3(SAM_UNK_INFO_3 * u_3)
+{
        u_3->unknown_0 = 0x00000000;
        u_3->unknown_1 = 0x80000000;
-
-       return True;
 }
 
 /*******************************************************************
 reads or writes a structure.
 ********************************************************************/
-static BOOL sam_io_unk_info3(char *desc, SAM_UNK_INFO_3 *u_3, prs_struct *ps, int depth)
+
+static BOOL sam_io_unk_info3(char *desc, SAM_UNK_INFO_3 * u_3,
+                            prs_struct *ps, int depth)
 {
        if (u_3 == NULL)
                return False;
@@ -484,31 +489,26 @@ static BOOL sam_io_unk_info3(char *desc, SAM_UNK_INFO_3 *u_3, prs_struct *ps, in
        if(!prs_uint32("unknown_1", ps, depth, &u_3->unknown_1))        /* 0x8000 0000 */
                return False;
 
-       if(!prs_align(ps))
-               return False;
-
        return True;
 }
 
 /*******************************************************************
-Inits a structure.
+inits a structure.
 ********************************************************************/
-BOOL init_unk_info6(SAM_UNK_INFO_6 * u_6)
-{
-       if (u_6 == NULL)
-               return False;
 
+void init_unk_info6(SAM_UNK_INFO_6 * u_6)
+{
        u_6->unknown_0 = 0x00000000;
        u_6->ptr_0 = 1;
        memset(u_6->padding, 0, sizeof(u_6->padding));  /* 12 bytes zeros */
-
-       return True;
 }
 
 /*******************************************************************
 reads or writes a structure.
 ********************************************************************/
-static BOOL sam_io_unk_info6(char *desc, SAM_UNK_INFO_6 *u_6, prs_struct *ps, int depth)
+
+static BOOL sam_io_unk_info6(char *desc, SAM_UNK_INFO_6 * u_6,
+                            prs_struct *ps, int depth)
 {
        if (u_6 == NULL)
                return False;
@@ -516,36 +516,31 @@ static BOOL sam_io_unk_info6(char *desc, SAM_UNK_INFO_6 *u_6, prs_struct *ps, in
        prs_debug(ps, depth, desc, "sam_io_unk_info6");
        depth++;
 
-       if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0))        /* 0x0000 0000 */
+       if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
                return False;
-       if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0))        /* pointer to unknown structure */
+       if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
                return False;
        if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding)))        /* 12 bytes zeros */
                return False;
 
-       if(!prs_align(ps))
-               return False;
-
        return True;
 }
 
 /*******************************************************************
-Inits a structure.
+inits a structure.
 ********************************************************************/
-BOOL init_unk_info7(SAM_UNK_INFO_7 *u_7)
-{
-       if (u_7 == NULL)
-               return False;
 
+void init_unk_info7(SAM_UNK_INFO_7 * u_7)
+{
        u_7->unknown_0 = 0x0003;
-
-       return True;
 }
 
 /*******************************************************************
 reads or writes a structure.
 ********************************************************************/
-static BOOL sam_io_unk_info7(char *desc, SAM_UNK_INFO_7 *u_7, prs_struct *ps, int depth)
+
+static BOOL sam_io_unk_info7(char *desc, SAM_UNK_INFO_7 * u_7,
+                            prs_struct *ps, int depth)
 {
        if (u_7 == NULL)
                return False;
@@ -553,37 +548,32 @@ static BOOL sam_io_unk_info7(char *desc, SAM_UNK_INFO_7 *u_7, prs_struct *ps, in
        prs_debug(ps, depth, desc, "sam_io_unk_info7");
        depth++;
 
-       if(!prs_uint16("unknown_0", ps, depth, &u_7->unknown_0))        /* 0x0003 */
-               return False;
-       if(!prs_align(ps))
+       if(!prs_uint16("unknown_0", ps, depth, &u_7->unknown_0)) /* 0x0003 */
                return False;
 
        return True;
 }
 
 /*******************************************************************
-Inits a structure.
+inits a structure.
 ********************************************************************/
-BOOL init_unk_info12(SAM_UNK_INFO_12 * u_12)
-{
-       if (u_12 == NULL)
-               return False;
 
+void init_unk_info12(SAM_UNK_INFO_12 * u_12)
+{
        u_12->unknown_0 = 0xcf1dcc00;
        u_12->unknown_1 = 0xfffffffb;
        u_12->unknown_2 = 0xcf1dcc00;
        u_12->unknown_3 = 0xfffffffb;
 
        u_12->unknown_4 = 0x8a880000;
-
-       return True;
 }
 
 /*******************************************************************
 reads or writes a structure.
 ********************************************************************/
+
 static BOOL sam_io_unk_info12(char *desc, SAM_UNK_INFO_12 * u_12,
-                            prs_struct *ps, int depth)
+                             prs_struct *ps, int depth)
 {
        if (u_12 == NULL)
                return False;
@@ -602,323 +592,247 @@ static BOOL sam_io_unk_info12(char *desc, SAM_UNK_INFO_12 * u_12,
        if(!prs_uint32("unknown_4", ps, depth, &u_12->unknown_4))
                return False;
 
-       if(!prs_align(ps))
-               return False;
-
        return True;
 }
 
 /*******************************************************************
- Inits a SAMR_R_QUERY_DOMAIN_INFO structure.
+inits a structure.
 ********************************************************************/
-
-void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO *r_u, 
-                               uint16 switch_value, SAM_UNK_CTR *ctr,
-                               uint32 status)
+void init_unk_info2(SAM_UNK_INFO_2 * u_2,
+                       char *domain, char *server,
+                       uint32 seq_num)
 {
-       DEBUG(5,("init_samr_r_query_dom_info\n"));
+       int len_domain = strlen(domain);
+       int len_server = strlen(server);
 
-       r_u->ptr_0 = 0;
-       r_u->switch_value = 0;
-       r_u->status = status; /* return status */
+       u_2->unknown_0 = 0x00000000;
+       u_2->unknown_1 = 0x80000000;
+       u_2->unknown_2 = 0x00000000;
 
-       if (status == 0) {
-               r_u->switch_value = switch_value;
-               r_u->ptr_0 = 1;
-               r_u->ctr = ctr;
-       }
+       u_2->ptr_0 = 1;
+       init_uni_hdr(&u_2->hdr_domain, len_domain);
+       init_uni_hdr(&u_2->hdr_server, len_server);
+
+       u_2->seq_num = seq_num;
+       u_2->unknown_3 = 0x00000000;
+
+       u_2->unknown_4 = 0x00000001;
+       u_2->unknown_5 = 0x00000003;
+       u_2->unknown_6 = 0x00000001;
+       u_2->num_domain_usrs = MAX_SAM_ENTRIES;
+       u_2->num_domain_grps = MAX_SAM_ENTRIES;
+       u_2->num_local_grps = MAX_SAM_ENTRIES;
+
+       memset(u_2->padding, 0, sizeof(u_2->padding));  /* 12 bytes zeros */
+
+       init_unistr2(&u_2->uni_domain, domain, len_domain);
+       init_unistr2(&u_2->uni_server, server, len_server);
 }
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_query_dom_info(char *desc, SAMR_R_QUERY_DOMAIN_INFO *r_u, prs_struct *ps, int depth)
+static BOOL sam_io_unk_info2(char *desc, SAM_UNK_INFO_2 * u_2,
+                            prs_struct *ps, int depth)
 {
-       if (r_u == NULL)
+       if (u_2 == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
+       prs_debug(ps, depth, desc, "sam_io_unk_info2");
        depth++;
 
-       if(!prs_align(ps))
+       if(!prs_uint32("unknown_0", ps, depth, &u_2->unknown_0)) /* 0x0000 0000 */
                return False;
-
-       if(!prs_uint32("ptr_0       ", ps, depth, &r_u->ptr_0))
+       if(!prs_uint32("unknown_1", ps, depth, &u_2->unknown_1)) /* 0x8000 0000 */
                return False;
-
-       if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
-               if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
-                       return False;
-               if(!prs_align(ps))
-                       return False;
-
-               switch (r_u->switch_value) {
-               case 0x01:
-                       if(!sam_io_unk_info1("unk_inf1", &r_u->ctr->info.inf1, ps, depth))
-                               return False;
-                       break;
-               case 0x02:
-                       if(!sam_io_unk_info2("unk_inf2", &r_u->ctr->info.inf2, ps, depth))
-                               return False;
-                       break;
-               case 0x03:
-                       if(!sam_io_unk_info3("unk_inf3", &r_u->ctr->info.inf3, ps, depth))
-                               return False;
-                       break;
-               case 0x06:
-                       if(!sam_io_unk_info6("unk_inf6", &r_u->ctr->info.inf6, ps, depth))
-                               return False;
-                       break;
-               case 0x07:
-                       if(!sam_io_unk_info7("unk_inf7", &r_u->ctr->info.inf7, ps, depth))
-                               return False;
-                       break;
-               case 0x0c:
-                       if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
-                               return False;
-                       break;
-               default:
-                       DEBUG(3,("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
-                                 r_u->switch_value));
-                       return False;
-               }
-       }
-
-       if(!prs_uint32("status", ps, depth, &r_u->status))
+       if(!prs_uint32("unknown_2", ps, depth, &u_2->unknown_2))        /* 0x0000 0000 */
                return False;
 
-       return True;
-}
-
-
-/*******************************************************************
- Inits a DOM_SID3 structure.
- Calculate length by adding up the size of the components.
- ********************************************************************/
-
-void init_dom_sid3(DOM_SID3 *sid3, uint16 unk_0, uint16 unk_1, DOM_SID *sid)
-{
-       sid3->sid = *sid;
-       sid3->len = 2 + 8 + sid3->sid.num_auths * 4;
-}
-
-/*******************************************************************
- Reads or writes a SAM_SID3 structure.
-
- this one's odd, because the length (in bytes) is specified at the beginning.
- the length _includes_ the length of the length, too :-)
+       if(!prs_uint32("ptr_0", ps, depth, &u_2->ptr_0))
+               return False;
+       if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
+               return False;
+       if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
+               return False;
 
-********************************************************************/
+       /* put all the data in here, at the moment, including what the above
+          pointer is referring to
+        */
 
-static BOOL sam_io_dom_sid3(char *desc,  DOM_SID3 *sid3, prs_struct *ps, int depth)
-{
-       if (sid3 == NULL)
+       if(!prs_uint32("seq_num ", ps, depth, &u_2->seq_num))   /* 0x0000 0099 or 0x1000 0000 */
+               return False;
+       if(!prs_uint32("unknown_3 ", ps, depth, &u_2->unknown_3))       /* 0x0000 0000 */
                return False;
 
-       prs_debug(ps, depth, desc, "sam_io_dom_sid3");
-       depth++;
+       if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
+               return False;
+       if(!prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5)) /* 0x0000 0003 */
+               return False;
+       if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
+               return False;
+       if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
+               return False;
+       if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
+               return False;
+       if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
+               return False;
 
-       if(!prs_uint16("len", ps, depth, &sid3->len))
+       if(!prs_uint8s(False, "padding", ps, depth, u_2->padding,sizeof(u_2->padding)))
                return False;
-       if(!prs_align(ps))
+
+       if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
                return False;
-       if(!smb_io_dom_sid("", &sid3->sid, ps, depth))
+       if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
                return False;
 
        return True;
 }
 
 /*******************************************************************
- Inits a SAMR_R_UNKNOWN3 structure.
-
-unknown_2   : 0x0001
-unknown_3   : 0x8004
-
-unknown_4,5 : 0x0000 0014
-
-unknown_6   : 0x0002
-unknown_7   : 0x5800 or 0x0070
-
+inits a structure.
 ********************************************************************/
 
-static void init_sam_sid_stuff(SAM_SID_STUFF *stf,
-                               uint16 unknown_2, uint16 unknown_3,
-                               uint32 unknown_4, uint16 unknown_6, uint16 unknown_7,
-                               int num_sid3s, DOM_SID3 sid3[MAX_SAM_SIDS])
+void init_unk_info1(SAM_UNK_INFO_1 * u_1)
 {
-       stf->unknown_2 = unknown_2;
-       stf->unknown_3 = unknown_3;
-
-       memset((char *)stf->padding1, '\0', sizeof(stf->padding1));
-
-       stf->unknown_4 = unknown_4;
-       stf->unknown_5 = unknown_4;
-
-       stf->unknown_6 = unknown_6;
-       stf->unknown_7 = unknown_7;
-
-       stf->num_sids  = num_sid3s;
-
-       stf->padding2  = 0x0000;
-
-       memcpy(stf->sid, sid3, sizeof(DOM_SID3) * num_sid3s);
+       memset(u_1->padding, 0, sizeof(u_1->padding));  /* 12 bytes zeros */
+       u_1->unknown_1 = 0x80000000;
+       u_1->unknown_2 = 0x00000000;
 }
 
 /*******************************************************************
- Reads or writes a SAM_SID_STUFF structure.
+reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_sid_stuff(char *desc,  SAM_SID_STUFF *stf, prs_struct *ps, int depth)
+static BOOL sam_io_unk_info1(char *desc, SAM_UNK_INFO_1 * u_1,
+                            prs_struct *ps, int depth)
 {
-       int i;
-
-       if (stf == NULL)
-               return False;
-
-       DEBUG(5,("init_sam_sid_stuff\n"));
+       if (u_1 == NULL)
+         return False;
 
-       if(!prs_uint16("unknown_2", ps, depth, &stf->unknown_2))
-               return False;
-       if(!prs_uint16("unknown_3", ps, depth, &stf->unknown_3))
-               return False;
+       prs_debug(ps, depth, desc, "sam_io_unk_info1");
+       depth++;
 
-       if(!prs_uint8s(False, "padding1", ps, depth, stf->padding1, sizeof(stf->padding1)))
+       if(!prs_uint8s(False, "padding", ps, depth, u_1->padding, sizeof(u_1->padding)))
                return False;
        
-       if(!prs_uint32("unknown_4", ps, depth, &stf->unknown_4))
-               return False;
-       if(!prs_uint32("unknown_5", ps, depth, &stf->unknown_5))
-               return False;
-       if(!prs_uint16("unknown_6", ps, depth, &stf->unknown_6))
-               return False;
-       if(!prs_uint16("unknown_7", ps, depth, &stf->unknown_7))
-               return False;
-
-       if(!prs_uint32("num_sids ", ps, depth, &stf->num_sids ))
+       if(!prs_uint32("unknown_1", ps, depth, &u_1->unknown_1)) /* 0x8000 0000 */
                return False;
-       if(!prs_uint16("padding2 ", ps, depth, &stf->padding2 ))
+       if(!prs_uint32("unknown_2", ps, depth, &u_1->unknown_2)) /* 0x0000 0000 */
                return False;
 
-       SMB_ASSERT_ARRAY(stf->sid, stf->num_sids);
-
-       for (i = 0; i < stf->num_sids; i++) {
-               if(!sam_io_dom_sid3("", &(stf->sid[i]), ps, depth))
-                       return False;
-       }
-
        return True;
 }
 
 /*******************************************************************
- Inits or writes a SAMR_R_UNKNOWN3 structure.
+inits a SAMR_R_QUERY_DOMAIN_INFO structure.
 ********************************************************************/
 
-void init_samr_r_unknown_3(SAMR_R_UNKNOWN_3 *r_u,
-                               uint16 unknown_2, uint16 unknown_3,
-                               uint32 unknown_4, uint16 unknown_6, uint16 unknown_7,
-                               int num_sid3s, DOM_SID3 sid3[MAX_SAM_SIDS],
+void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
+                               uint16 switch_value, SAM_UNK_CTR * ctr,
                                uint32 status)
 {
-       DEBUG(5,("samr_init_r_unknown_3\n"));
+       DEBUG(5, ("init_samr_r_query_dom_info\n"));
 
        r_u->ptr_0 = 0;
-       r_u->ptr_1 = 0;
+       r_u->switch_value = 0;
+       r_u->status = status;   /* return status */
 
-       if (status == 0x0) {
+       if (status == 0) {
+               r_u->switch_value = switch_value;
                r_u->ptr_0 = 1;
-               r_u->ptr_1 = 1;
-               init_sam_sid_stuff(&(r_u->sid_stuff), unknown_2, unknown_3,
-                      unknown_4, unknown_6, unknown_7,
-                      num_sid3s, sid3);
+               r_u->ctr = ctr;
        }
-
-       r_u->status = status;
 }
 
 /*******************************************************************
- Reads or writes a SAMR_R_UNKNOWN_3 structure.
-
-this one's odd, because the daft buggers use a different mechanism
-for writing out the array of sids. they put the number of sids in
-only one place: they've calculated the length of each sid and jumped
-by that amount.  then, retrospectively, the length of the whole buffer
-is put at the beginning of the data stream.
-
-wierd.  
-
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_unknown_3(char *desc,  SAMR_R_UNKNOWN_3 *r_u, prs_struct *ps, int depth)
+BOOL samr_io_r_query_dom_info(char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
+                             prs_struct *ps, int depth)
 {
-       int ptr_len0=0;
-       int ptr_len1=0;
-       int ptr_sid_stuff = 0;
-
-       if (r_u == NULL)
+        if (r_u == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_r_unknown_3");
+       prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!prs_uint32("ptr_0         ", ps, depth, &r_u->ptr_0))
+       if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
                return False;
 
-       if (ps->io) {
-               /* reading.  do the length later */
-               if(!prs_uint32("sid_stuff_len0", ps, depth, &r_u->sid_stuff_len0))
+       if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
+               if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
                        return False;
-       } else {
-               /* storing */
-               ptr_len0 = prs_offset(ps);
-               if(!prs_set_offset(ps, ptr_len0 + 4))
+               if(!prs_align(ps))
                        return False;
-       }
 
-       if (r_u->ptr_0 != 0) {
-               if(!prs_uint32("ptr_1         ", ps, depth, &r_u->ptr_1))
-                       return False;
-               if (ps->io) {
-                       /* reading.  do the length later */
-                       if(!prs_uint32("sid_stuff_len1", ps, depth, &r_u->sid_stuff_len1))
+               switch (r_u->switch_value) {
+               case 0x0c:
+                       if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
+                               return False;
+                       break;
+               case 0x07:
+                       if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
                                return False;
-               } else {
-                       /* storing */
-                       ptr_len1 = prs_offset(ps);
-                       if(!prs_set_offset(ps, ptr_len1 + 4))
+                       break;
+               case 0x06:
+                       if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
                                return False;
-               }
-
-               if (r_u->ptr_1 != 0) {
-                       ptr_sid_stuff = prs_offset(ps);
-                       if(!sam_io_sid_stuff("", &r_u->sid_stuff, ps, depth))
+                       break;
+               case 0x03:
+                       if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
                                return False;
+                       break;
+               case 0x02:
+                       if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
+                               return False;
+                       break;
+               case 0x01:
+                       if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
+                               return False;
+                       break;
+               default:
+                       DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
+                               r_u->switch_value));
+                       r_u->status = NT_STATUS_INVALID_INFO_CLASS;
+                       return False;
                }
        }
+       
+       if(!prs_align(ps))
+               return False;
 
-       if (!(ps->io)) {
-               /* storing not reading.  do the length, now. */
+       if(!prs_uint32("status", ps, depth, &r_u->status))
+               return False;
+       
+       return True;
+}
 
-               if (ptr_sid_stuff != 0) {
-                       int old_len = prs_offset(ps);
-                       uint32 sid_stuff_len = old_len - ptr_sid_stuff;
+/*******************************************************************
+reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
+********************************************************************/
 
-                       if(!prs_set_offset(ps, ptr_len0))
-                               return False;
-                       if(!prs_uint32("sid_stuff_len0", ps, depth, &sid_stuff_len))
-                               return False;
+BOOL samr_io_r_query_sec_obj(char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
+                            prs_struct *ps, int depth)
+{
+       if (r_u == NULL)
+               return False;
+  
+       prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
+       depth++;
 
-                       if(!prs_set_offset(ps, ptr_len1))
-                               return False;
-                       if(!prs_uint32("sid_stuff_len1", ps, depth, &sid_stuff_len))
-                               return False;
+       if(!prs_align(ps))
+               return False;
 
-                       if(!prs_set_offset(ps, old_len))
-                               return False;
-               }
+       if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
+               return False;
+       if (r_u->ptr != 0) {
+               if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
+                       return False;
        }
 
        if(!prs_uint32("status", ps, depth, &r_u->status))
@@ -928,11 +842,12 @@ BOOL samr_io_r_unknown_3(char *desc,  SAMR_R_UNKNOWN_3 *r_u, prs_struct *ps, int
 }
 
 /*******************************************************************
- Reads or writes a SAM_STR1 structure.
+reads or writes a SAM_STR1 structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_str1(char *desc, SAM_STR1 *sam, uint32 acct_buf,
-                               uint32 name_buf, uint32 desc_buf, prs_struct *ps, int depth)
+static BOOL sam_io_sam_str1(char *desc, SAM_STR1 * sam, uint32 acct_buf,
+                           uint32 name_buf, uint32 desc_buf,
+                           prs_struct *ps, int depth)
 {
        if (sam == NULL)
                return False;
@@ -942,31 +857,35 @@ static BOOL sam_io_sam_str1(char *desc, SAM_STR1 *sam, uint32 acct_buf,
 
        if(!prs_align(ps))
                return False;
-
-       if(!smb_io_unistr2("unistr2", &sam->uni_acct_name, acct_buf, ps, depth)) /* account name unicode string */
+       if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
                return False;
-       if(!smb_io_unistr2("unistr2", &sam->uni_full_name, name_buf, ps, depth)) /* full name unicode string */
+
+       if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
                return False;
-       if(!smb_io_unistr2("unistr2", &sam->uni_acct_desc, desc_buf, ps, depth)) /* account description unicode string */
+
+       if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
                return False;
 
        return True;
 }
 
 /*******************************************************************
- Inits a SAM_ENTRY1 structure.
+inits a SAM_ENTRY1 structure.
 ********************************************************************/
 
-static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx, 
-                               uint32 len_sam_name, uint32 len_sam_full, uint32 len_sam_desc,
-                               uint32 rid_user, uint16 acb_info)
+static void init_sam_entry1(SAM_ENTRY1 * sam, uint32 user_idx,
+                           uint32 len_sam_name, uint32 len_sam_full,
+                           uint32 len_sam_desc, uint32 rid_user,
+                           uint16 acb_info)
 {
-       DEBUG(5,("init_sam_entry1\n"));
+       DEBUG(5, ("init_sam_entry1\n"));
+
+       ZERO_STRUCTP(sam);
 
        sam->user_idx = user_idx;
        sam->rid_user = rid_user;
        sam->acb_info = acb_info;
-       sam->pad      = 0;
+       sam->pad = 0;
 
        init_uni_hdr(&sam->hdr_acct_name, len_sam_name);
        init_uni_hdr(&sam->hdr_user_name, len_sam_full);
@@ -974,10 +893,11 @@ static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
 }
 
 /*******************************************************************
- Reads or writes a SAM_ENTRY1 structure.
+reads or writes a SAM_ENTRY1 structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_entry1(char *desc,  SAM_ENTRY1 *sam, prs_struct *ps, int depth)
+static BOOL sam_io_sam_entry1(char *desc, SAM_ENTRY1 * sam,
+                             prs_struct *ps, int depth)
 {
        if (sam == NULL)
                return False;
@@ -998,21 +918,22 @@ static BOOL sam_io_sam_entry1(char *desc,  SAM_ENTRY1 *sam, prs_struct *ps, int
        if(!prs_uint16("pad      ", ps, depth, &sam->pad))
                return False;
 
-       if(!smb_io_unihdr("unihdr", &sam->hdr_acct_name, ps, depth)) /* account name unicode string header */
+       if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
                return False;
-       if(!smb_io_unihdr("unihdr", &sam->hdr_user_name, ps, depth)) /* account name unicode string header */
+       if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
                return False;
-       if(!smb_io_unihdr("unihdr", &sam->hdr_user_desc, ps, depth)) /* account name unicode string header */
+       if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
                return False;
 
        return True;
 }
 
 /*******************************************************************
- Reads or writes a SAM_STR2 structure.
+reads or writes a SAM_STR2 structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_str2(char *desc,  SAM_STR2 *sam, uint32 acct_buf, uint32 desc_buf, prs_struct *ps, int depth)
+static BOOL sam_io_sam_str2(char *desc, SAM_STR2 * sam, uint32 acct_buf,
+                           uint32 desc_buf, prs_struct *ps, int depth)
 {
        if (sam == NULL)
                return False;
@@ -1023,38 +944,38 @@ static BOOL sam_io_sam_str2(char *desc,  SAM_STR2 *sam, uint32 acct_buf, uint32
        if(!prs_align(ps))
                return False;
 
-       if(!smb_io_unistr2("unistr2", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
+       if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
                return False;
-       if(!smb_io_unistr2("unistr2", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account description unicode string */
+       if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth))    /* account desc unicode string */
                return False;
 
        return True;
 }
 
 /*******************************************************************
- Inits a SAM_ENTRY2 structure.
+inits a SAM_ENTRY2 structure.
 ********************************************************************/
-
-static void init_sam_entry2(SAM_ENTRY2 *sam, uint32 user_idx, 
-                               uint32 len_sam_name, uint32 len_sam_desc,
-                               uint32 rid_user, uint16 acb_info)
+static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
+                           uint32 len_sam_name, uint32 len_sam_desc,
+                           uint32 rid_user, uint16 acb_info)
 {
-       DEBUG(5,("init_sam_entry2\n"));
+       DEBUG(5, ("init_sam_entry2\n"));
 
        sam->user_idx = user_idx;
        sam->rid_user = rid_user;
        sam->acb_info = acb_info;
-       sam->pad      = 0;
+       sam->pad = 0;
 
        init_uni_hdr(&sam->hdr_srv_name, len_sam_name);
        init_uni_hdr(&sam->hdr_srv_desc, len_sam_desc);
 }
 
 /*******************************************************************
- Reads or writes a SAM_ENTRY2 structure.
+reads or writes a SAM_ENTRY2 structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_entry2(char *desc,  SAM_ENTRY2 *sam, prs_struct *ps, int depth)
+static BOOL sam_io_sam_entry2(char *desc, SAM_ENTRY2 * sam,
+                             prs_struct *ps, int depth)
 {
        if (sam == NULL)
                return False;
@@ -1075,19 +996,20 @@ static BOOL sam_io_sam_entry2(char *desc,  SAM_ENTRY2 *sam, prs_struct *ps, int
        if(!prs_uint16("pad      ", ps, depth, &sam->pad))
                return False;
 
-       if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
+       if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth))     /* account name unicode string header */
                return False;
-       if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
+       if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth))     /* account name unicode string header */
                return False;
 
        return True;
 }
 
 /*******************************************************************
- Reads or writes a SAM_STR3 structure.
+reads or writes a SAM_STR3 structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_str3(char *desc,  SAM_STR3 *sam, uint32 acct_buf, uint32 desc_buf, prs_struct *ps, int depth)
+static BOOL sam_io_sam_str3(char *desc, SAM_STR3 * sam, uint32 acct_buf,
+                           uint32 desc_buf, prs_struct *ps, int depth)
 {
        if (sam == NULL)
                return False;
@@ -1098,37 +1020,38 @@ static BOOL sam_io_sam_str3(char *desc,  SAM_STR3 *sam, uint32 acct_buf, uint32
        if(!prs_align(ps))
                return False;
 
-       if(!smb_io_unistr2("unistr2", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
+       if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth))    /* account name unicode string */
                return False;
-       if(!smb_io_unistr2("unistr2", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account description unicode string */
+       if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth))    /* account desc unicode string */
                return False;
 
        return True;
 }
 
 /*******************************************************************
- Inits a SAM_ENTRY3 structure.
+inits a SAM_ENTRY3 structure.
 ********************************************************************/
 
-static void init_sam_entry3(SAM_ENTRY3 *sam, uint32 grp_idx, 
-                               uint32 len_grp_name, uint32 len_grp_desc, uint32 rid_grp)
+static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
+                           uint32 len_grp_name, uint32 len_grp_desc,
+                           uint32 rid_grp)
 {
-       DEBUG(5,("init_sam_entry3\n"));
+       DEBUG(5, ("init_sam_entry3\n"));
 
-       ZERO_STRUCTP(sam);
        sam->grp_idx = grp_idx;
        sam->rid_grp = rid_grp;
-       sam->attr    = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
+       sam->attr = 0x07;       /* group rid attributes - gets ignored by nt 4.0 */
 
        init_uni_hdr(&sam->hdr_grp_name, len_grp_name);
        init_uni_hdr(&sam->hdr_grp_desc, len_grp_desc);
 }
 
 /*******************************************************************
- Reads or writes a SAM_ENTRY3 structure.
+reads or writes a SAM_ENTRY3 structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_entry3(char *desc,  SAM_ENTRY3 *sam, prs_struct *ps, int depth)
+static BOOL sam_io_sam_entry3(char *desc, SAM_ENTRY3 * sam,
+                             prs_struct *ps, int depth)
 {
        if (sam == NULL)
                return False;
@@ -1147,257 +1070,170 @@ static BOOL sam_io_sam_entry3(char *desc,  SAM_ENTRY3 *sam, prs_struct *ps, int
        if(!prs_uint32("attr   ", ps, depth, &sam->attr))
                return False;
 
-       if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
+       if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth))     /* account name unicode string header */
                return False;
-       if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
+       if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth))     /* account name unicode string header */
                return False;
 
        return True;
 }
 
 /*******************************************************************
- Inits a SAM_ENTRY structure.
+inits a SAM_ENTRY4 structure.
 ********************************************************************/
 
-static void init_sam_entry(SAM_ENTRY *sam, uint32 len_sam_name, uint32 rid)
+static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
+                           uint32 len_acct_name)
 {
-       DEBUG(5,("init_sam_entry\n"));
+       DEBUG(5, ("init_sam_entry4\n"));
 
-       sam->rid = rid;
-       init_uni_hdr(&sam->hdr_name, len_sam_name);
+       sam->user_idx = user_idx;
+       init_str_hdr(&sam->hdr_acct_name, len_acct_name, len_acct_name,
+                    len_acct_name != 0);
 }
 
 /*******************************************************************
- Reads or writes a SAM_ENTRY structure.
+reads or writes a SAM_ENTRY4 structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_entry(char *desc,  SAM_ENTRY *sam, prs_struct *ps, int depth)
+static BOOL sam_io_sam_entry4(char *desc, SAM_ENTRY4 * sam,
+                             prs_struct *ps, int depth)
 {
        if (sam == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "sam_io_sam_entry");
+       prs_debug(ps, depth, desc, "sam_io_sam_entry4");
        depth++;
 
        if(!prs_align(ps))
                return False;
-       if(!prs_uint32("rid", ps, depth, &sam->rid))
+
+       if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
                return False;
-       if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
+       if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
                return False;
 
        return True;
 }
 
-
 /*******************************************************************
- Inits a SAMR_Q_ENUM_DOM_USERS structure.
+inits a SAM_ENTRY5 structure.
 ********************************************************************/
 
-void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_e, POLICY_HND *pol,
-                               uint16 req_num_entries, uint16 unk_0,
-                               uint16 acb_mask, uint16 unk_1, uint32 size)
+static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
+                           uint32 len_grp_name)
 {
-       DEBUG(5,("init_q_enum_dom_users\n"));
+       DEBUG(5, ("init_sam_entry5\n"));
 
-       memcpy(&q_e->pol, pol, sizeof(*pol));
-
-       q_e->req_num_entries = req_num_entries; /* zero indicates lots */
-       q_e->unknown_0 = unk_0; /* this gets returned in the response */
-       q_e->acb_mask  = acb_mask;
-       q_e->unknown_1 = unk_1;
-       q_e->max_size = size;
+       sam->grp_idx = grp_idx;
+       init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
+                    len_grp_name != 0);
 }
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a SAM_ENTRY5 structure.
 ********************************************************************/
 
-BOOL samr_io_q_enum_dom_users(char *desc,  SAMR_Q_ENUM_DOM_USERS *q_e, prs_struct *ps, int depth)
+static BOOL sam_io_sam_entry5(char *desc, SAM_ENTRY5 * sam,
+                             prs_struct *ps, int depth)
 {
-       if (q_e == NULL)
+       if (sam == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
+       prs_debug(ps, depth, desc, "sam_io_sam_entry5");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
-               return False;
-       if(!prs_align(ps))
-               return False;
-
-       if(!prs_uint16("req_num_entries", ps, depth, &q_e->req_num_entries))
-               return False;
-       if(!prs_uint16("unknown_0      ", ps, depth, &q_e->unknown_0))
-               return False;
-
-       if(!prs_uint16("acb_mask       ", ps, depth, &q_e->acb_mask))
-               return False;
-       if(!prs_uint16("unknown_1      ", ps, depth, &q_e->unknown_1))
-               return False;
-
-       if(!prs_uint32("max_size       ", ps, depth, &q_e->max_size))
+       if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
                return False;
-
-       if(!prs_align(ps))
+       if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
                return False;
 
        return True;
 }
 
-
 /*******************************************************************
- Inits a SAMR_R_ENUM_DOM_USERS structure.
+inits a SAM_ENTRY structure.
 ********************************************************************/
 
-void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS *r_u,
-               uint16 total_num_entries, uint16 unk_0,
-               uint32 num_sam_entries, SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES], uint32 status)
+void init_sam_entry(SAM_ENTRY * sam, uint32 len_sam_name, uint32 rid)
 {
-       int i;
+       DEBUG(10, ("init_sam_entry: %d %d\n", len_sam_name, rid));
 
-       DEBUG(5,("init_samr_r_enum_dom_users\n"));
+       sam->rid = rid;
+       init_uni_hdr(&sam->hdr_name, len_sam_name);
+}
 
-       if (num_sam_entries >= MAX_SAM_ENTRIES) {
-               num_sam_entries = MAX_SAM_ENTRIES;
-               DEBUG(5,("limiting number of entries to %d\n",
-                        num_sam_entries));
-       }
+/*******************************************************************
+reads or writes a SAM_ENTRY structure.
+********************************************************************/
 
-       r_u->total_num_entries = total_num_entries;
-       r_u->unknown_0         = unk_0;
+static BOOL sam_io_sam_entry(char *desc, SAM_ENTRY * sam,
+                            prs_struct *ps, int depth)
+{
+       if (sam == NULL)
+               return False;
 
-       if (total_num_entries > 0) {
-               r_u->ptr_entries1 = 1;
-               r_u->ptr_entries2 = 1;
-               r_u->num_entries2 = num_sam_entries;
-               r_u->num_entries3 = num_sam_entries;
-
-               SMB_ASSERT_ARRAY(r_u->sam, num_sam_entries);
-               SMB_ASSERT_ARRAY(r_u->uni_acct_name, num_sam_entries);
-
-               for (i = 0; i < num_sam_entries; i++) {
-                       init_sam_entry(&(r_u->sam[i]),
-                                      pass[i].uni_user_name.uni_str_len,
-                                      pass[i].user_rid);
-
-                       copy_unistr2(&r_u->uni_acct_name[i], &(pass[i].uni_user_name));
-               }
-
-               r_u->num_entries4 = num_sam_entries;
-       } else {
-               r_u->ptr_entries1 = 0;
-               r_u->num_entries2 = num_sam_entries;
-               r_u->ptr_entries2 = 1;
-       }
-
-       r_u->status = status;
-}
-
-/*******************************************************************
- Reads or writes a structure.
-********************************************************************/
-
-BOOL samr_io_r_enum_dom_users(char *desc,  SAMR_R_ENUM_DOM_USERS *r_u, prs_struct *ps, int depth)
-{
-       int i;
-
-       if (r_u == NULL)
-               return False;
-
-       prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
+       prs_debug(ps, depth, desc, "sam_io_sam_entry");
        depth++;
 
        if(!prs_align(ps))
                return False;
-
-       if(!prs_uint16("total_num_entries", ps, depth, &r_u->total_num_entries))
-               return False;
-       if(!prs_uint16("unknown_0        ", ps, depth, &r_u->unknown_0))
-               return False;
-       if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
+       if(!prs_uint32("rid", ps, depth, &sam->rid))
                return False;
-
-       if (r_u->total_num_entries != 0 && r_u->ptr_entries1 != 0) {
-               if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
-                       return False;
-               if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
-                       return False;
-               if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
-                       return False;
-
-               SMB_ASSERT_ARRAY(r_u->sam, r_u->num_entries2);
-
-               for (i = 0; i < r_u->num_entries2; i++) {
-                       if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
-                               return False;
-               }
-
-               SMB_ASSERT_ARRAY(r_u->uni_acct_name, r_u->num_entries2);
-
-               for (i = 0; i < r_u->num_entries2; i++) {
-                       if(!smb_io_unistr2("", &r_u->uni_acct_name[i],
-                                       r_u->sam[i].hdr_name.buffer, ps, depth))
-                               return False;
-               }
-
-               if(!prs_align(ps))
-                       return False;
-
-               if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
-                       return False;
-       }
-
-       if(!prs_uint32("status", ps, depth, &r_u->status))
+       if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
                return False;
 
        return True;
 }
 
 /*******************************************************************
- Inits a SAMR_Q_ENUM_DOM_ALIASES structure.
+inits a SAMR_Q_ENUM_DOM_USERS structure.
 ********************************************************************/
 
-void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_e, POLICY_HND *pol, uint32 size)
+void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
+                               uint32 start_idx,
+                               uint16 acb_mask, uint16 unk_1, uint32 size)
 {
-       DEBUG(5,("init_q_enum_dom_aliases\n"));
+       DEBUG(5, ("init_samr_q_enum_dom_users\n"));
 
-       memcpy(&q_e->pol, pol, sizeof(*pol));
+       q_e->pol = *pol;
 
-       q_e->unknown_0 = 0;
+       q_e->start_idx = start_idx;     /* zero indicates lots */
+       q_e->acb_mask = acb_mask;
+       q_e->unknown_1 = unk_1;
        q_e->max_size = size;
 }
 
-
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_enum_dom_aliases(char *desc,  SAMR_Q_ENUM_DOM_ALIASES *q_e, prs_struct *ps, int depth)
+BOOL samr_io_q_enum_dom_users(char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
+                             prs_struct *ps, int depth)
 {
        if (q_e == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
+       prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
-               return False;
-       if(!prs_align(ps))
+       if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
                return False;
 
-       if(!prs_uint32("unknown_0", ps, depth, &q_e->unknown_0))
+       if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
                return False;
-       if(!prs_uint32("max_size ", ps, depth, &q_e->max_size ))
+       if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
+               return False;
+       if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
                return False;
 
-       if(!prs_align(ps))
+       if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
                return False;
 
        return True;
@@ -1405,72 +1241,54 @@ BOOL samr_io_q_enum_dom_aliases(char *desc,  SAMR_Q_ENUM_DOM_ALIASES *q_e, prs_s
 
 
 /*******************************************************************
- Inits a SAMR_R_ENUM_DOM_ALIASES structure.
+inits a SAMR_R_ENUM_DOM_USERS structure.
 ********************************************************************/
 
-void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u,
-               uint32 num_sam_entries, SAM_USER_INFO_21 grps[MAX_SAM_ENTRIES],
-               uint32 status)
+void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
+                               uint32 next_idx, uint32 num_sam_entries)
 {
-       int i;
-
-       DEBUG(5,("init_samr_r_enum_dom_aliases\n"));
-
-       if (num_sam_entries >= MAX_SAM_ENTRIES) {
-               num_sam_entries = MAX_SAM_ENTRIES;
-               DEBUG(5,("limiting number of entries to %d\n", 
-                        num_sam_entries));
-       }
+       DEBUG(5, ("init_samr_r_enum_dom_users\n"));
 
-       r_u->num_entries  = num_sam_entries;
+       r_u->next_idx = next_idx;
 
-       if (num_sam_entries > 0) {
-               r_u->ptr_entries  = 1;
-               r_u->num_entries2 = num_sam_entries;
+       if (num_sam_entries != 0) {
+               r_u->ptr_entries1 = 1;
                r_u->ptr_entries2 = 1;
+               r_u->num_entries2 = num_sam_entries;
                r_u->num_entries3 = num_sam_entries;
 
-               SMB_ASSERT_ARRAY(r_u->sam, num_sam_entries);
-
-               for (i = 0; i < num_sam_entries; i++) {
-                       init_sam_entry(&r_u->sam[i],
-                                      grps[i].uni_user_name.uni_str_len,
-                                      grps[i].user_rid);
-
-                       copy_unistr2(&r_u->uni_grp_name[i], &(grps[i].uni_user_name));
-               }
-
                r_u->num_entries4 = num_sam_entries;
        } else {
-               r_u->ptr_entries = 0;
+               r_u->ptr_entries1 = 0;
+               r_u->num_entries2 = num_sam_entries;
+               r_u->ptr_entries2 = 1;
        }
-
-       r_u->status = status;
 }
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_enum_dom_aliases(char *desc,  SAMR_R_ENUM_DOM_ALIASES *r_u, prs_struct *ps, int depth)
+BOOL samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
+                             prs_struct *ps, int depth)
 {
-       int i;
+       uint32 i;
 
        if (r_u == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
+       prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
+       if(!prs_uint32("next_idx    ", ps, depth, &r_u->next_idx))
                return False;
-       if(!prs_uint32("ptr_entries", ps, depth, &r_u->ptr_entries))
+       if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
                return False;
 
-       if (r_u->num_entries != 0 && r_u->ptr_entries != 0) {
+       if (r_u->ptr_entries1 != 0) {
                if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
                        return False;
                if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
@@ -1478,55 +1296,66 @@ BOOL samr_io_r_enum_dom_aliases(char *desc,  SAMR_R_ENUM_DOM_ALIASES *r_u, prs_s
                if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
                        return False;
 
-               SMB_ASSERT_ARRAY(r_u->sam, r_u->num_entries);
+               if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
+                       r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
+                       r_u->uni_acct_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
+               }
+
+               if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
+                       DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
+                       r_u->num_entries4 = 0;
+                       r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
+                       return False;
+               }
 
-               for (i = 0; i < r_u->num_entries; i++) {
+               for (i = 0; i < r_u->num_entries2; i++) {
                        if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
                                return False;
                }
 
-               for (i = 0; i < r_u->num_entries; i++) {
-                       if(!smb_io_unistr2("", &r_u->uni_grp_name[i], r_u->sam[i].hdr_name.buffer, ps, depth))
+               for (i = 0; i < r_u->num_entries2; i++) {
+                       if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
                                return False;
                }
 
-               if(!prs_align(ps))
-                       return False;
-
-               if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
-                       return False;
        }
 
+       if(!prs_align(ps))
+               return False;
+               
+       if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
+               return False;
        if(!prs_uint32("status", ps, depth, &r_u->status))
                return False;
 
        return True;
 }
 
-
 /*******************************************************************
- Inits a SAMR_Q_QUERY_DISPINFO structure.
+inits a SAMR_Q_QUERY_DISPINFO structure.
 ********************************************************************/
 
-void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_e, POLICY_HND *pol,
-                               uint16 switch_level, uint32 start_idx, uint32 size)
+void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
+                               uint16 switch_level, uint32 start_idx,
+                               uint32 max_entries)
 {
-       DEBUG(5,("init_q_query_dispinfo\n"));
+       DEBUG(5, ("init_samr_q_query_dispinfo\n"));
 
-       memcpy(&q_e->pol, pol, sizeof(*pol));
+       q_e->domain_pol = *pol;
 
        q_e->switch_level = switch_level;
 
        q_e->start_idx = start_idx;
-       q_e->max_entries = 0;
-       q_e->max_size  = size;
+       q_e->max_entries = max_entries;
+       q_e->max_size = 0xffff; /* Not especially useful */
 }
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_query_dispinfo(char *desc,  SAMR_Q_QUERY_DISPINFO *q_e, prs_struct *ps, int depth)
+BOOL samr_io_q_query_dispinfo(char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
+                             prs_struct *ps, int depth)
 {
        if (q_e == NULL)
                return False;
@@ -1537,19 +1366,14 @@ BOOL samr_io_q_query_dispinfo(char *desc,  SAMR_Q_QUERY_DISPINFO *q_e, prs_struc
        if(!prs_align(ps))
                return False;
 
-       if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
-               return False;
-       if(!prs_align(ps))
+       if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
                return False;
 
        if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
                return False;
-#if 0
-       if(!prs_uint16("unknown_0   ", ps, depth, &q_e->unknown_0))
+       if(!prs_align(ps))
                return False;
-#else
-       prs_align(ps);
-#endif
+
        if(!prs_uint32("start_idx   ", ps, depth, &q_e->start_idx))
                return False;
        if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
@@ -1557,90 +1381,82 @@ BOOL samr_io_q_query_dispinfo(char *desc,  SAMR_Q_QUERY_DISPINFO *q_e, prs_struc
        if(!prs_uint32("max_size    ", ps, depth, &q_e->max_size))
                return False;
 
-       if(!prs_align(ps))
-               return False;
-
        return True;
 }
 
-
 /*******************************************************************
- Inits a SAM_INFO_2 structure.
+inits a SAM_DISPINFO_1 structure.
 ********************************************************************/
 
-void init_sam_info_2(SAM_INFO_2 *sam, uint32 acb_mask,
-               uint32 start_idx, uint32 num_sam_entries,
-               SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES])
+void init_sam_dispinfo_1(SAM_DISPINFO_1 * sam, uint32 *num_entries,
+                        uint32 *data_size, uint32 start_idx,
+                        SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES])
 {
-       int i;
-       int entries_added;
+       uint32 len_sam_name, len_sam_full, len_sam_desc;
+       uint32 max_entries, max_data_size;
+       uint32 dsize = 0;
+       uint32 i;
 
-       DEBUG(5,("init_sam_info_2\n"));
+       ZERO_STRUCTP(sam);
 
-       if (num_sam_entries >= MAX_SAM_ENTRIES) {
-               num_sam_entries = MAX_SAM_ENTRIES;
-               DEBUG(5,("limiting number of entries to %d\n", 
-                        num_sam_entries));
-       }
+       max_entries = *num_entries;
+       max_data_size = *data_size;
 
-       for (i = start_idx, entries_added = 0; i < num_sam_entries; i++) {
-               if ((pass[i].acb_info & acb_mask) == acb_mask) {
-                       init_sam_entry2(&sam->sam[entries_added],
-                                       start_idx + entries_added + 1,
-                                       pass[i].uni_user_name.uni_str_len,
-                                       pass[i].uni_acct_desc.uni_str_len,
-                                       pass[i].user_rid,
-                                       pass[i].acb_info);
+       DEBUG(5, ("init_sam_dispinfo_1: max_entries: %d max_dsize: 0x%x\n",
+                 max_entries, max_data_size));
 
-                       copy_unistr2(&sam->str[entries_added].uni_srv_name, &pass[i].uni_user_name);
-                       copy_unistr2(&sam->str[entries_added].uni_srv_desc, &pass[i].uni_acct_desc);
+       for (i = 0; (i < max_entries) && (dsize < max_data_size); i++) {
+               len_sam_name = pass[i].uni_user_name.uni_str_len;
+               len_sam_full = pass[i].uni_full_name.uni_str_len;
+               len_sam_desc = pass[i].uni_acct_desc.uni_str_len;
 
-                       entries_added++;
-               }
+               init_sam_entry1(&sam->sam[i], start_idx + i + 1,
+                               len_sam_name, len_sam_full, len_sam_desc,
+                               pass[i].user_rid, pass[i].acb_info);
 
-               sam->num_entries   = entries_added;
-               sam->ptr_entries   = 1;
-               sam->num_entries2  = entries_added;
+               copy_unistr2(&sam->str[i].uni_acct_name, &pass[i].uni_user_name);
+               copy_unistr2(&sam->str[i].uni_full_name, &pass[i].uni_full_name);
+               copy_unistr2(&sam->str[i].uni_acct_desc, &pass[i].uni_acct_desc);
+
+               dsize += sizeof(SAM_ENTRY1);
+               dsize += len_sam_name + len_sam_full + len_sam_desc;
        }
+
+       *num_entries = i;
+       *data_size = dsize;
 }
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_info_2(char *desc,  SAM_INFO_2 *sam, prs_struct *ps, int depth)
+static BOOL sam_io_sam_dispinfo_1(char *desc, SAM_DISPINFO_1 * sam,
+                                 uint32 num_entries,
+                                 prs_struct *ps, int depth)
 {
-       int i;
+       uint32 i;
 
        if (sam == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "sam_io_sam_info_2");
+       prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!prs_uint32("num_entries  ", ps, depth, &sam->num_entries))
-               return False;
-       if(!prs_uint32("ptr_entries  ", ps, depth, &sam->ptr_entries))
-               return False;
-
-       if(!prs_uint32("num_entries2 ", ps, depth, &sam->num_entries2))
-               return False;
+       SMB_ASSERT_ARRAY(sam->sam, num_entries);
 
-       SMB_ASSERT_ARRAY(sam->sam, sam->num_entries);
-
-       for (i = 0; i < sam->num_entries; i++) {
-               if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
+       for (i = 0; i < num_entries; i++) {
+               if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
                        return False;
        }
 
-       for (i = 0; i < sam->num_entries; i++) {
-               if(!sam_io_sam_str("", &sam->str[i],
-                                sam->sam[i].hdr_srv_name.buffer,
-                                sam->sam[i].hdr_srv_desc.buffer,
-                                ps, depth))
+       for (i = 0; i < num_entries; i++) {
+               if(!sam_io_sam_str1("", &sam->str[i],
+                             sam->sam[i].hdr_acct_name.buffer,
+                             sam->sam[i].hdr_user_name.buffer,
+                             sam->sam[i].hdr_user_desc.buffer, ps, depth))
                        return False;
        }
 
@@ -1648,896 +1464,824 @@ static BOOL sam_io_sam_info_2(char *desc,  SAM_INFO_2 *sam, prs_struct *ps, int
 }
 
 /*******************************************************************
- Inits a SAM_INFO_1 structure.
+inits a SAM_DISPINFO_2 structure.
 ********************************************************************/
 
-void init_sam_info_1(SAM_INFO_1 *sam, uint32 acb_mask,
-               uint32 start_idx, uint32 num_sam_entries,
-               SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES])
+void init_sam_dispinfo_2(SAM_DISPINFO_2 * sam, uint32 *num_entries,
+                        uint32 *data_size, uint32 start_idx,
+                        SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES])
 {
-       int i;
-       int entries_added;
+       uint32 len_sam_name, len_sam_desc;
+       uint32 max_entries, max_data_size;
+       uint32 dsize = 0;
+       uint32 i;
 
-       DEBUG(5,("init_sam_info_1\n"));
+       DEBUG(5, ("init_sam_dispinfo_2\n"));
 
-       if (num_sam_entries >= MAX_SAM_ENTRIES) {
-               num_sam_entries = MAX_SAM_ENTRIES;
-               DEBUG(5,("limiting number of entries to %d\n", 
-                        num_sam_entries));
-       }
-       DEBUG(5,("num_sam_entries: %u, start_idx: %u\n",num_sam_entries,
-                num_sam_entries));
-
-       for (i = 0, entries_added = 0; 
-            i < num_sam_entries; i++) {
-               if ((pass[i].acb_info & acb_mask) == acb_mask) {
-                       init_sam_entry1(&sam->sam[entries_added],
-                                               start_idx + entries_added + 1,
-                                               pass[i].uni_user_name.uni_str_len,
-                                               pass[i].uni_full_name.uni_str_len, 
-                                               pass[i].uni_acct_desc.uni_str_len,
-                                               pass[i].user_rid,
-                                               pass[i].acb_info);
-
-                       copy_unistr2(&sam->str[entries_added].uni_acct_name, &pass[i].uni_user_name);
-                       copy_unistr2(&sam->str[entries_added].uni_full_name, &pass[i].uni_full_name);
-                       copy_unistr2(&sam->str[entries_added].uni_acct_desc, &pass[i].uni_acct_desc);
-
-                       entries_added++;
-               } 
+       ZERO_STRUCTP(sam);
+
+       max_entries = *num_entries;
+       max_data_size = *data_size;
+
+       for (i = 0; (i < max_entries) && (dsize < max_data_size); i++) {
+               len_sam_name = pass[i].uni_user_name.uni_str_len;
+               len_sam_desc = pass[i].uni_acct_desc.uni_str_len;
+         
+               init_sam_entry2(&sam->sam[i], start_idx + i + 1,
+                         len_sam_name, len_sam_desc,
+                         pass[i].user_rid, pass[i].acb_info);
+         
+               copy_unistr2(&sam->str[i].uni_srv_name,
+                      &pass[i].uni_user_name);
+               copy_unistr2(&sam->str[i].uni_srv_desc,
+                      &pass[i].uni_acct_desc);
+         
+               dsize += sizeof(SAM_ENTRY2);
+               dsize += len_sam_name + len_sam_desc;
        }
 
-       sam->num_entries   = entries_added;
-       sam->ptr_entries   = 1;
-       sam->num_entries2  = entries_added;
+       *num_entries = i;
+       *data_size = dsize;
 }
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_info_1(char *desc,  SAM_INFO_1 *sam, prs_struct *ps, int depth)
+static BOOL sam_io_sam_dispinfo_2(char *desc, SAM_DISPINFO_2 * sam,
+                                 uint32 num_entries,
+                                 prs_struct *ps, int depth)
 {
-       int i;
+       uint32 i;
 
        if (sam == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "sam_io_sam_info_1");
+       prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!prs_uint32("num_entries  ", ps, depth, &sam->num_entries))
-               return False;
-       if(!prs_uint32("ptr_entries  ", ps, depth, &sam->ptr_entries))
-               return False;
-
-       if(!prs_uint32("num_entries2 ", ps, depth, &sam->num_entries2))
-               return False;
-
-       SMB_ASSERT_ARRAY(sam->sam, sam->num_entries);
+       SMB_ASSERT_ARRAY(sam->sam, num_entries);
 
-       for (i = 0; i < sam->num_entries; i++) {
-               if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
+       for (i = 0; i < num_entries; i++) {
+               if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
                        return False;
        }
 
-       for (i = 0; i < sam->num_entries; i++) {
-               if(!sam_io_sam_str1 ("", &sam->str[i],
-                                                        sam->sam[i].hdr_acct_name.buffer,
-                                                        sam->sam[i].hdr_user_name.buffer,
-                                                        sam->sam[i].hdr_user_desc.buffer,
-                                                        ps, depth))
-               return False;
+       for (i = 0; i < num_entries; i++) {
+               if(!sam_io_sam_str2("", &sam->str[i],
+                             sam->sam[i].hdr_srv_name.buffer,
+                             sam->sam[i].hdr_srv_desc.buffer, ps, depth))
+                       return False;
        }
 
        return True;
 }
 
 /*******************************************************************
- Inits a SAMR_R_QUERY_DISPINFO structure.
+inits a SAM_DISPINFO_3 structure.
 ********************************************************************/
 
-void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO *r_u,
-               uint16 switch_level, SAM_INFO_CTR *ctr, uint32 status)
+void init_sam_dispinfo_3(SAM_DISPINFO_3 * sam, uint32 *num_entries,
+                        uint32 *data_size, uint32 start_idx,
+                        DOMAIN_GRP * grp)
 {
-       DEBUG(5,("init_samr_r_query_dispinfo\n"));
+       uint32 len_sam_name, len_sam_desc;
+       uint32 max_entries, max_data_size;
+       uint32 dsize = 0;
+       uint32 i;
 
-       if (status == 0x0 || status == 0x105) {
-               r_u->unknown_0 = 0x0000001;
-               r_u->unknown_1 = 0x0000001;
-       } else {
-               r_u->unknown_0 = 0x0;
-               r_u->unknown_1 = 0x0;
+       DEBUG(5, ("init_sam_dispinfo_3\n"));
+
+       ZERO_STRUCTP(sam);
+
+       max_entries = *num_entries;
+       max_data_size = *data_size;
+
+       for (i = 0; (i < max_entries) && (dsize < max_data_size); i++) {
+               len_sam_name = strlen(grp[i].name);
+               len_sam_desc = strlen(grp[i].comment);
+
+               init_sam_entry3(&sam->sam[i], start_idx + i + 1, len_sam_name, len_sam_desc, grp[i].rid);
+         
+               init_unistr2(&sam->str[i].uni_grp_name, grp[i].name, len_sam_name);
+               init_unistr2(&sam->str[i].uni_grp_desc, grp[i].comment, len_sam_desc);
+         
+               dsize += sizeof(SAM_ENTRY3);
+               dsize += (len_sam_name + len_sam_desc) * 2;
+               dsize += 14;
        }
 
-       r_u->switch_level = switch_level;
-       r_u->ctr = ctr;
-       r_u->status = status;
+       *num_entries = i;
+       *data_size = dsize;
 }
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_query_dispinfo(char *desc,  SAMR_R_QUERY_DISPINFO *r_u, prs_struct *ps, int depth)
+static BOOL sam_io_sam_dispinfo_3(char *desc, SAM_DISPINFO_3 * sam,
+                                 uint32 num_entries,
+                                 prs_struct *ps, int depth)
 {
-       if (r_u == NULL)
+       uint32 i;
+
+       if (sam == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
+       prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!prs_uint32("unknown_0    ", ps, depth, &r_u->unknown_0))
-               return False;
-       if(!prs_uint32("unknown_1    ", ps, depth, &r_u->unknown_1))
-               return False;
-       if(!prs_uint16("switch_level ", ps, depth, &r_u->switch_level))
-               return False;
-
-       if(!prs_align(ps))
-               return False;
+       SMB_ASSERT_ARRAY(sam->sam, num_entries);
 
-       switch (r_u->switch_level) {
-       case 0x1:
-               if(!sam_io_sam_info_1("users", r_u->ctr->sam.info1, ps, depth))
+       for (i = 0; i < num_entries; i++) {
+               if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
                        return False;
-               break;
-       case 0x2:
-               if(!sam_io_sam_info_2("servers", r_u->ctr->sam.info2, ps, depth))
-                       return False;
-               break;
-       default:
-               DEBUG(5,("samr_io_r_query_dispinfo: unknown switch value\n"));
-               break;
        }
 
-       if(!prs_uint32("status", ps, depth, &r_u->status))
-               return False;
+       for (i = 0; i < num_entries; i++) {
+               if(!sam_io_sam_str3("", &sam->str[i],
+                             sam->sam[i].hdr_grp_name.buffer,
+                             sam->sam[i].hdr_grp_desc.buffer, ps, depth))
+                       return False;
+       }
 
        return True;
 }
 
 /*******************************************************************
- Inits a SAMR_Q_ENUM_DOM_GROUPS structure.
+inits a SAM_DISPINFO_4 structure.
 ********************************************************************/
 
-void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_e, POLICY_HND *pol,
-                               uint16 switch_level, uint32 start_idx, uint32 size)
+void init_sam_dispinfo_4(SAM_DISPINFO_4 * sam, uint32 *num_entries,
+                        uint32 *data_size, uint32 start_idx,
+                        SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES])
 {
-       DEBUG(5,("init_q_enum_dom_groups\n"));
+       fstring sam_name;
+       uint32 len_sam_name;
+       uint32 max_entries, max_data_size;
+       uint32 dsize = 0;
+       uint32 i;
 
-       memcpy(&q_e->pol, pol, sizeof(*pol));
+       DEBUG(5, ("init_sam_dispinfo_4\n"));
 
-       q_e->switch_level = switch_level;
+       ZERO_STRUCTP(sam);
 
-       q_e->unknown_0 = 0;
-       q_e->start_idx = start_idx;
-       q_e->unknown_1 = 0x000007d0;
-       q_e->max_size  = size;
+       max_entries = *num_entries;
+       max_data_size = *data_size;
+
+       for (i = 0; (i < max_entries) && (dsize < max_data_size); i++) {
+               len_sam_name = pass[i].uni_user_name.uni_str_len;
+         
+               init_sam_entry4(&sam->sam[i], start_idx + i + 1,
+                         len_sam_name);
+         
+               unistr2_to_ascii(sam_name, &pass[i].uni_user_name,
+                          sizeof(sam_name));
+               init_string2(&sam->str[i].acct_name, sam_name,
+                      len_sam_name);
+         
+               dsize += sizeof(SAM_ENTRY4);
+               dsize += len_sam_name;
+       }
+       
+       *num_entries = i;
+       *data_size = dsize;
 }
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_enum_dom_groups(char *desc,  SAMR_Q_ENUM_DOM_GROUPS *q_e, prs_struct *ps, int depth)
+static BOOL sam_io_sam_dispinfo_4(char *desc, SAM_DISPINFO_4 * sam,
+                                 uint32 num_entries,
+                                 prs_struct *ps, int depth)
 {
-       if (q_e == NULL)
+       uint32 i;
+
+       if (sam == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
+       prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
-               return False;
-       if(!prs_align(ps))
-               return False;
+       SMB_ASSERT_ARRAY(sam->sam, num_entries);
 
-       if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
-               return False;
-       if(!prs_uint16("unknown_0   ", ps, depth, &q_e->unknown_0))
-               return False;
-       if(!prs_uint32("start_idx   ", ps, depth, &q_e->start_idx))
-               return False;
-       if(!prs_uint32("unknown_1   ", ps, depth, &q_e->unknown_1))
-               return False;
-       if(!prs_uint32("max_size    ", ps, depth, &q_e->max_size))
-               return False;
+       for (i = 0; i < num_entries; i++) {
+               if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
+                       return False;
+       }
 
-       if(!prs_align(ps))
-               return False;
+       for (i = 0; i < num_entries; i++) {
+               if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
+                            sam->sam[i].hdr_acct_name.buffer, ps, depth))
+                       return False;
+               if(!prs_align(ps))
+                       return False;
+       }
 
        return True;
 }
 
-
 /*******************************************************************
- Inits a SAMR_R_ENUM_DOM_GROUPS structure.
+inits a SAM_DISPINFO_5 structure.
 ********************************************************************/
 
-void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS *r_u,
-               uint32 start_idx, uint32 num_sam_entries,
-               SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES],
-               uint32 status)
+void init_sam_dispinfo_5(SAM_DISPINFO_5 * sam, uint32 *num_entries,
+                        uint32 *data_size, uint32 start_idx,
+                        DOMAIN_GRP * grp)
 {
-       int i;
-       int entries_added;
+       uint32 len_sam_name;
+       uint32 max_entries, max_data_size;
+       uint32 dsize = 0;
+       uint32 i;
 
-       DEBUG(5,("init_samr_r_enum_dom_groups\n"));
+       DEBUG(5, ("init_sam_dispinfo_5\n"));
 
-       if (num_sam_entries >= MAX_SAM_ENTRIES) {
-               num_sam_entries = MAX_SAM_ENTRIES;
-               DEBUG(5,("limiting number of entries to %d\n", 
-                        num_sam_entries));
-       }
+       ZERO_STRUCTP(sam);
 
-       if (status == 0x0) {
-               for (i = start_idx, entries_added = 0; i < num_sam_entries; i++) {
-                       init_sam_entry3(&r_u->sam[entries_added],
-                                       start_idx + entries_added + 1,
-                                       pass[i].uni_user_name.uni_str_len,
-                                       pass[i].uni_acct_desc.uni_str_len,
-                                       pass[i].user_rid);
-
-                       copy_unistr2(&r_u->str[entries_added].uni_grp_name, 
-                                               &pass[i].uni_user_name);
-                       copy_unistr2(&r_u->str[entries_added].uni_grp_desc, 
-                                               &pass[i].uni_acct_desc);
-
-                       entries_added++;
-               }
+       max_entries = *num_entries;
+       max_data_size = *data_size;
 
-               if (entries_added > 0) {
-                       r_u->unknown_0 = 0x0000492;
-                       r_u->unknown_1 = 0x000049a;
-               } else {
-                       r_u->unknown_0 = 0x0;
-                       r_u->unknown_1 = 0x0;
-               }
-               r_u->switch_level  = 3;
-               r_u->num_entries   = entries_added;
-               r_u->ptr_entries   = 1;
-               r_u->num_entries2  = entries_added;
-       } else {
-               r_u->switch_level = 0;
+       for (i = 0; (i < max_entries) && (dsize < max_data_size); i++) {
+               len_sam_name = strlen(grp[i].name);
+         
+               init_sam_entry5(&sam->sam[i], start_idx + i + 1,
+                               len_sam_name);
+         
+               init_string2(&sam->str[i].grp_name, grp[i].name,
+                               len_sam_name);
+         
+               dsize += sizeof(SAM_ENTRY5);
+               dsize += len_sam_name;
        }
-
-       r_u->status = status;
+       
+       *num_entries = i;
+       *data_size = dsize;
 }
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_enum_dom_groups(char *desc,  SAMR_R_ENUM_DOM_GROUPS *r_u, prs_struct *ps, int depth)
+static BOOL sam_io_sam_dispinfo_5(char *desc, SAM_DISPINFO_5 * sam,
+                                 uint32 num_entries,
+                                 prs_struct *ps, int depth)
 {
-       int i;
+       uint32 i;
 
-       if (r_u == NULL)
+       if (sam == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
+       prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!prs_uint32("unknown_0    ", ps, depth, &r_u->unknown_0))
-               return False;
-       if(!prs_uint32("unknown_1    ", ps, depth, &r_u->unknown_1))
-               return False;
-       if(!prs_uint32("switch_level ", ps, depth, &r_u->switch_level))
-               return False;
+       SMB_ASSERT_ARRAY(sam->sam, num_entries);
 
-       if (r_u->switch_level != 0) {
-               if(!prs_uint32("num_entries  ", ps, depth, &r_u->num_entries))
-                       return False;
-               if(!prs_uint32("ptr_entries  ", ps, depth, &r_u->ptr_entries))
+       for (i = 0; i < num_entries; i++) {
+               if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
                        return False;
+       }
 
-               if(!prs_uint32("num_entries2 ", ps, depth, &r_u->num_entries2))
+       for (i = 0; i < num_entries; i++) {
+               if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
+                            sam->sam[i].hdr_grp_name.buffer, ps, depth))
+                       return False;
+               if(!prs_align(ps))
                        return False;
-
-               SMB_ASSERT_ARRAY(r_u->sam, r_u->num_entries);
-
-               for (i = 0; i < r_u->num_entries; i++) {
-                       if(!sam_io_sam_entry3("", &r_u->sam[i], ps, depth))
-                               return False;
-               }
-
-               for (i = 0; i < r_u->num_entries; i++) {
-                       if(!sam_io_sam_str3 ("", &r_u->str[i],
-                                            r_u->sam[i].hdr_grp_name.buffer,
-                                            r_u->sam[i].hdr_grp_desc.buffer,
-                                            ps, depth))
-                               return False;
-               }
        }
 
-       if(!prs_uint32("status", ps, depth, &r_u->status))
-               return False;
-
        return True;
 }
 
 /*******************************************************************
- Inits a SAMR_Q_QUERY_ALIASINFO structure.
+inits a SAMR_R_QUERY_DISPINFO structure.
 ********************************************************************/
 
-void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_e,
-                               POLICY_HND *pol,
-                               uint16 switch_level)
+void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
+                               uint32 num_entries, uint32 data_size,
+                               uint16 switch_level, SAM_DISPINFO_CTR * ctr,
+                               uint32 status)
 {
-       DEBUG(5,("init_q_query_aliasinfo\n"));
+       DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
 
-       memcpy(&q_e->pol, pol, sizeof(*pol));
+       r_u->total_size = data_size;    /* not calculated */
+       r_u->data_size = data_size;
 
-       q_e->switch_level = switch_level;
+       r_u->switch_level = switch_level;
+       r_u->num_entries = num_entries;
+
+       if (num_entries==0)
+               r_u->ptr_entries = 0;
+       else
+               r_u->ptr_entries = 1;
+
+       r_u->num_entries2 = num_entries;
+       r_u->ctr = ctr;
+
+       r_u->status = status;
 }
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_query_aliasinfo(char *desc,  SAMR_Q_QUERY_ALIASINFO *q_e, prs_struct *ps, int depth)
+BOOL samr_io_r_query_dispinfo(char *desc, SAMR_R_QUERY_DISPINFO * r_u,
+                             prs_struct *ps, int depth)
 {
-       if (q_e == NULL)
+       if (r_u == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
+       prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
+       if(!prs_uint32("total_size  ", ps, depth, &r_u->total_size))
+               return False;
+       if(!prs_uint32("data_size   ", ps, depth, &r_u->data_size))
+               return False;
+       if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
                return False;
        if(!prs_align(ps))
                return False;
 
-       if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
+       if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
+               return False;
+       if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
                return False;
 
-       return True;
-}
-
-/*******************************************************************
- Inits a SAMR_R_QUERY_ALIASINFO structure.
-********************************************************************/
-
-void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *r_u, uint32 switch_level,
-                                char* alias, char* alias_desc)
-                                
-{
-  int alias_desc_len, alias_len;
-
-  if(r_u == NULL)
-    return;
-
-  alias_len = alias?strlen(alias)+1:0;
-  alias_desc_len = alias_desc?strlen(alias_desc)+1:0;
+       if (r_u->ptr_entries==0) {
+               if(!prs_align(ps))
+                       return False;
+               if(!prs_uint32("status", ps, depth, &r_u->status))
+                       return False;
 
-  DEBUG(5,("init_samr_r_query_aliasinfo\n"));
+               return True;
+       }
 
-  r_u->switch_value = switch_level;
+       if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
+               return False;
 
-  if(r_u->status == 0)
-    {
-      switch(switch_level)
-       {
-       case 1: 
-         {
-           r_u->ptr = 1;
-           init_uni_hdr(&r_u->alias.info1.hdr_alias_name, alias_len);
-           init_unistr2(&r_u->alias.info1.uni_alias_name, alias, alias_len);
-           r_u->alias.info1.switch_value_1 = switch_level;
-           init_uni_hdr(&r_u->alias.info1.hdr_alias_desc, alias_desc_len);
-           init_unistr2(&r_u->alias.info1.uni_alias_desc, alias_desc, alias_desc_len);
-           break;
-         }
-       case 3:
-         {
-           r_u->ptr = 1;
-           init_uni_hdr(&r_u->alias.info3.hdr_acct_desc, alias_desc_len);
-           init_unistr2(&r_u->alias.info3.uni_acct_desc, alias_desc, alias_desc_len);
-           break;
-         }
+       switch (r_u->switch_level) {
+       case 0x1:
+               if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
+                               r_u->num_entries, ps, depth))
+                       return False;
+               break;
+       case 0x2:
+               if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
+                               r_u->num_entries, ps, depth))
+                       return False;
+               break;
+       case 0x3:
+               if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
+                                   r_u->num_entries, ps, depth))
+                       return False;
+               break;
+       case 0x4:
+               if(!sam_io_sam_dispinfo_4("user list",
+                                   r_u->ctr->sam.info4,
+                                   r_u->num_entries, ps, depth))
+                       return False;
+               break;
+       case 0x5:
+               if(!sam_io_sam_dispinfo_5("group list",
+                                   r_u->ctr->sam.info5,
+                                   r_u->num_entries, ps, depth))
+                       return False;
+               break;
        default:
-         {
-           r_u->status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS;
-         }
+               DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
+               break;
        }
-    }
-}
+       
+       if(!prs_align(ps))
+               return False;
+       if(!prs_uint32("status", ps, depth, &r_u->status))
+               return False;
 
-         
+       return True;
+}
 
 /*******************************************************************
- Reads or writes a structure.
+inits a SAMR_Q_OPEN_GROUP structure.
 ********************************************************************/
 
-BOOL samr_io_r_query_aliasinfo(char *desc,  SAMR_R_QUERY_ALIASINFO *r_u, prs_struct *ps, int depth)
+void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
+                           POLICY_HND *hnd,
+                           uint32 access_mask, uint32 rid)
 {
-  if (r_u == NULL)
-    return False;
-
-  prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
-  depth++;
-
-  if(!prs_align(ps))
-    return False;
-
-  if(!prs_uint32("ptr         ", ps, depth, &r_u->ptr))
-    return False;
-       
-  if (r_u->ptr != 0) {
-    if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
-      return False;
-    if(!prs_align(ps))
-      return False;
-
-    if (r_u->switch_value != 0) {
-      switch (r_u->switch_value) {
-      case 1:
-       smb_io_unihdr("",&r_u->alias.info1.hdr_alias_name, ps, depth);
-       prs_uint32("switch_value_1", ps, depth, &r_u->alias.info1.switch_value_1);
-       smb_io_unihdr("",&r_u->alias.info1.hdr_alias_desc, ps, depth);
-       
-       smb_io_unistr2("", &r_u->alias.info1.uni_alias_name, 
-                      r_u->alias.info1.hdr_alias_name.buffer, ps, depth);
-       smb_io_unistr2("", &r_u->alias.info1.uni_alias_desc,
-                      r_u->alias.info1.hdr_alias_desc.buffer, ps, depth);
-       break;
-      case 3:
-       if(!smb_io_unihdr ("", &r_u->alias.info3.hdr_acct_desc, ps, depth))
-         return False;
-       if(!smb_io_unistr2("", &r_u->alias.info3.uni_acct_desc, 
-                          r_u->alias.info3.hdr_acct_desc.buffer, ps, depth))
-         return False;
-       break;
-      default:
-       DEBUG(4,("samr_io_r_query_aliasinfo: unsupported switch level\n"));
-       break;
-      }
-    }
-  }
+       DEBUG(5, ("init_samr_q_open_group\n"));
 
-  if(!prs_align(ps))
-    return False;
-
-  if(!prs_uint32("status", ps, depth, &r_u->status))
-    return False;
-
-  return True;
+       q_c->domain_pol = *hnd;
+       q_c->access_mask = access_mask;
+       q_c->rid_group = rid;
 }
 
 /*******************************************************************
- Reads or writes a SAMR_Q_LOOKUP_IDS structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_lookup_ids(char *desc,  SAMR_Q_LOOKUP_IDS *q_u, prs_struct *ps, int depth)
+BOOL samr_io_q_open_group(char *desc, SAMR_Q_OPEN_GROUP * q_u,
+                         prs_struct *ps, int depth)
 {
-       fstring tmp;
-       int i;
-
        if (q_u == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_q_lookup_ids");
+       prs_debug(ps, depth, desc, "samr_io_q_open_group");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!smb_io_pol_hnd("pol", &(q_u->pol), ps, depth))
-               return False;
-       if(!prs_align(ps))
+       if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
                return False;
 
-       if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
-               return False;
-       if(!prs_uint32("ptr      ", ps, depth, &q_u->ptr))
+       if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
                return False;
-       if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
+       if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
                return False;
 
-       SMB_ASSERT_ARRAY(q_u->ptr_sid, q_u->num_sids2);
+       return True;
+}
 
-       for (i = 0; i < q_u->num_sids2; i++) {
-               slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
-               if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
-                       return False;
-       }
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
 
-       for (i = 0; i < q_u->num_sids2; i++) {
-               if (q_u->ptr_sid[i] != 0) {
-                       slprintf(tmp, sizeof(tmp)-1, "sid[%02d]", i);
-                       if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
-                               return False;
-               }
-       }
+BOOL samr_io_r_open_group(char *desc, SAMR_R_OPEN_GROUP * r_u,
+                         prs_struct *ps, int depth)
+{
+       if (r_u == NULL)
+               return False;
+
+       prs_debug(ps, depth, desc, "samr_io_r_open_group");
+       depth++;
 
        if(!prs_align(ps))
                return False;
 
+       if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
+               return False;
+
+       if(!prs_uint32("status", ps, depth, &r_u->status))
+               return False;
+
        return True;
 }
 
 /*******************************************************************
- Inits a SAMR_R_LOOKUP_IDS structure.
+inits a GROUP_INFO1 structure.
 ********************************************************************/
 
-void init_samr_r_lookup_ids(SAMR_R_LOOKUP_IDS *r_u,
-               uint32 num_rids, uint32 *rid, uint32 status)
+void init_samr_group_info1(GROUP_INFO1 * gr1,
+                          char *acct_name, char *acct_desc,
+                          uint32 num_members)
 {
-       int i;
+       int desc_len = acct_desc != NULL ? strlen(acct_desc) : 0;
+       int acct_len = acct_name != NULL ? strlen(acct_name) : 0;
 
-       DEBUG(5,("init_samr_r_lookup_ids\n"));
+       DEBUG(5, ("init_samr_group_info1\n"));
 
-       if (status == 0x0) {
-               r_u->num_entries  = num_rids;
-               r_u->ptr = 1;
-               r_u->num_entries2 = num_rids;
+       init_uni_hdr(&gr1->hdr_acct_name, acct_len);
 
-               SMB_ASSERT_ARRAY(r_u->rid, num_rids);
+       gr1->unknown_1 = 0x3;
+       gr1->num_members = num_members;
 
-               for (i = 0; i < num_rids; i++) {
-                       r_u->rid[i] = rid[i];
-               }
-       } else {
-               r_u->num_entries  = 0;
-               r_u->ptr = 0;
-               r_u->num_entries2 = 0;
-       }
+       init_uni_hdr(&gr1->hdr_acct_desc, desc_len);
 
-       r_u->status = status;
+       init_unistr2(&gr1->uni_acct_name, acct_name, acct_len);
+       init_unistr2(&gr1->uni_acct_desc, acct_desc, desc_len);
 }
 
 /*******************************************************************
- Reads or writes a structure.
+reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_lookup_ids(char *desc,  SAMR_R_LOOKUP_IDS *r_u, prs_struct *ps, int depth)
+BOOL samr_io_group_info1(char *desc, GROUP_INFO1 * gr1,
+                        prs_struct *ps, int depth)
 {
-       fstring tmp;
-       int i;
-
-       if (r_u == NULL)
+       if (gr1 == NULL)
                return False;
 
-       prs_debug(ps, depth, desc, "samr_io_r_lookup_ids");
+       prs_debug(ps, depth, desc, "samr_io_group_info1");
        depth++;
 
        if(!prs_align(ps))
                return False;
 
-       if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
+       if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
                return False;
-       if(!prs_uint32("ptr        ", ps, depth, &r_u->ptr))
+
+       if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
                return False;
-       if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
+       if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
                return False;
 
-       if (r_u->num_entries != 0) {
-               SMB_ASSERT_ARRAY(r_u->rid, r_u->num_entries2);
+       if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
+               return False;
 
-               for (i = 0; i < r_u->num_entries2; i++) {
-                       slprintf(tmp, sizeof(tmp)-1, "rid[%02d]", i);
-                       if(!prs_uint32(tmp, ps, depth, &r_u->rid[i]))
-                               return False;
-               }
-       }
+       if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
+                          gr1->hdr_acct_name.buffer, ps, depth))
+               return False;
 
-       if(!prs_uint32("status", ps, depth, &r_u->status))
+       if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
+                          gr1->hdr_acct_desc.buffer, ps, depth))
                return False;
 
        return True;
 }
 
 /*******************************************************************
- Reads or writes a structure.
+inits a GROUP_INFO4 structure.
 ********************************************************************/
 
-BOOL samr_io_q_lookup_names(char *desc,  SAMR_Q_LOOKUP_NAMES *q_u, prs_struct *ps, int depth)
+void init_samr_group_info4(GROUP_INFO4 * gr4, char *acct_desc)
 {
-       int i;
+       int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
 
-       if (q_u == NULL)
-               return False;
+       DEBUG(5, ("init_samr_group_info4\n"));
 
-       prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
-       depth++;
+       init_uni_hdr(&gr4->hdr_acct_desc, acct_len);
+       init_unistr2(&gr4->uni_acct_desc, acct_desc, acct_len);
+}
 
-       prs_align(ps);
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
 
-       if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
+BOOL samr_io_group_info4(char *desc, GROUP_INFO4 * gr4,
+                        prs_struct *ps, int depth)
+{
+       if (gr4 == NULL)
                return False;
+
+       prs_debug(ps, depth, desc, "samr_io_group_info4");
+       depth++;
+
        if(!prs_align(ps))
                return False;
 
-       if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
-               return False;
-       if(!prs_uint32("flags     ", ps, depth, &q_u->flags))
+       if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
                return False;
-       if(!prs_uint32("ptr      ", ps, depth, &q_u->ptr))
+       if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
+                          gr4->hdr_acct_desc.buffer, ps, depth))
                return False;
-       if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
+
+       return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+
+static BOOL samr_group_info_ctr(char *desc, GROUP_INFO_CTR * ctr,
+                               prs_struct *ps, int depth)
+{
+       if (ctr == NULL)
                return False;
 
-       SMB_ASSERT_ARRAY(q_u->hdr_name, q_u->num_names2);
+       prs_debug(ps, depth, desc, "samr_group_info_ctr");
+       depth++;
 
-       for (i = 0; i < q_u->num_names2; i++) {
-               if(!smb_io_unihdr ("", &q_u->hdr_name[i], ps, depth))
+       if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
+               return False;
+       if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
+               return False;
+
+       switch (ctr->switch_value1) {
+       case 1:
+               if(!samr_io_group_info1("group_info1",
+                                 &ctr->group.info1, ps, depth))
                        return False;
-       }
-       for (i = 0; i < q_u->num_names2; i++) {
-               if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
+               break;
+       case 4:
+               if(!samr_io_group_info4("group_info4",
+                                 &ctr->group.info4, ps, depth))
                        return False;
+               break;
+       default:
+               DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
+               break;
        }
 
        return True;
 }
 
-
 /*******************************************************************
- Inits a SAMR_R_LOOKUP_NAMES structure.
+inits a SAMR_Q_CREATE_DOM_GROUP structure.
 ********************************************************************/
-void init_samr_r_lookup_names(SAMR_R_LOOKUP_NAMES *r_u,
-                       uint32 num_rids, uint32 *rid, enum SID_NAME_USE *type, uint32 status)
-{
-       int i;
-
-       DEBUG(5,("init_samr_r_lookup_names\n"));
-
-       if (status == 0x0) {
-  &nb