Change all uint32/16/8 to 32_t/16_t/8_t in winbindd.
[kamenim/samba-autobuild/.git] / source3 / winbindd / winbindd_samr.c
index 40c0bb6bbbea7bdea1f306cbc9f9e3ef1f23eac5..b94dfc8dc6e55fdd1a4afbf80aebfdc894f99d8c 100644 (file)
 #include "includes.h"
 #include "winbindd.h"
 #include "winbindd_rpc.h"
-
+#include "rpc_client/rpc_client.h"
 #include "../librpc/gen_ndr/ndr_samr_c.h"
 #include "rpc_client/cli_samr.h"
-#include "../librpc/gen_ndr/srv_samr.h"
 #include "../librpc/gen_ndr/ndr_lsa_c.h"
 #include "rpc_client/cli_lsarpc.h"
-#include "../librpc/gen_ndr/srv_lsa.h"
 #include "rpc_server/rpc_ncacn_np.h"
 #include "../libcli/security/security.h"
+#include "passdb/machine_sid.h"
+#include "auth.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_WINBIND
 
-static NTSTATUS open_internal_samr_pipe(TALLOC_CTX *mem_ctx,
-                                       struct rpc_pipe_client **samr_pipe)
-{
-       struct rpc_pipe_client *cli = NULL;
-       struct auth_serversupplied_info *session_info = NULL;
-       NTSTATUS status;
-
-       if (cli != NULL) {
-               goto done;
-       }
-
-       if (session_info == NULL) {
-               status = make_session_info_system(mem_ctx, &session_info);
-               if (!NT_STATUS_IS_OK(status)) {
-                       DEBUG(0, ("open_samr_pipe: Could not create auth_serversupplied_info: %s\n",
-                                 nt_errstr(status)));
-                       return status;
-               }
-       }
-
-       /* create a samr connection */
-       status = rpc_pipe_open_interface(mem_ctx,
-                                       &ndr_table_samr.syntax_id,
-                                       session_info,
-                                       NULL,
-                                       winbind_messaging_context(),
-                                       &cli);
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(0, ("open_samr_pipe: Could not connect to samr_pipe: %s\n",
-                         nt_errstr(status)));
-               return status;
-       }
-
-done:
-       if (samr_pipe) {
-               *samr_pipe = cli;
-       }
-
-       return NT_STATUS_OK;
-}
-
 NTSTATUS open_internal_samr_conn(TALLOC_CTX *mem_ctx,
                                 struct winbindd_domain *domain,
                                 struct rpc_pipe_client **samr_pipe,
@@ -89,7 +48,7 @@ NTSTATUS open_internal_samr_conn(TALLOC_CTX *mem_ctx,
        struct policy_handle samr_connect_hnd;
        struct dcerpc_binding_handle *b;
 
-       status = open_internal_samr_pipe(mem_ctx, samr_pipe);
+       status = wb_open_internal_pipe(mem_ctx, &ndr_table_samr, samr_pipe);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -121,54 +80,13 @@ NTSTATUS open_internal_samr_conn(TALLOC_CTX *mem_ctx,
        return result;
 }
 
-static NTSTATUS open_internal_lsa_pipe(TALLOC_CTX *mem_ctx,
-                                      struct rpc_pipe_client **lsa_pipe)
+NTSTATUS open_internal_lsa_conn(TALLOC_CTX *mem_ctx,
+                               struct rpc_pipe_client **lsa_pipe,
+                               struct policy_handle *lsa_hnd)
 {
-       struct rpc_pipe_client *cli = NULL;
-       struct auth_serversupplied_info *session_info = NULL;
        NTSTATUS status;
 
-       if (cli != NULL) {
-               goto done;
-       }
-
-       if (session_info == NULL) {
-               status = make_session_info_system(mem_ctx, &session_info);
-               if (!NT_STATUS_IS_OK(status)) {
-                       DEBUG(0, ("open_lsa_pipe: Could not create auth_serversupplied_info: %s\n",
-                                 nt_errstr(status)));
-                       return status;
-               }
-       }
-
-       /* create a lsa connection */
-       status = rpc_pipe_open_interface(mem_ctx,
-                                       &ndr_table_lsarpc.syntax_id,
-                                       session_info,
-                                       NULL,
-                                       winbind_messaging_context(),
-                                       &cli);
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(0, ("open_lsa_pipe: Could not connect to lsa_pipe: %s\n",
-                         nt_errstr(status)));
-               return status;
-       }
-
-done:
-       if (lsa_pipe) {
-               *lsa_pipe = cli;
-       }
-
-       return NT_STATUS_OK;
-}
-
-static NTSTATUS open_internal_lsa_conn(TALLOC_CTX *mem_ctx,
-                                      struct rpc_pipe_client **lsa_pipe,
-                                      struct policy_handle *lsa_hnd)
-{
-       NTSTATUS status;
-
-       status = open_internal_lsa_pipe(mem_ctx, lsa_pipe);
+       status = wb_open_internal_pipe(mem_ctx, &ndr_table_lsarpc, lsa_pipe);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -190,11 +108,11 @@ static NTSTATUS open_internal_lsa_conn(TALLOC_CTX *mem_ctx,
 static NTSTATUS sam_enum_dom_groups(struct winbindd_domain *domain,
                                    TALLOC_CTX *mem_ctx,
                                    uint32_t *pnum_info,
-                                   struct acct_info **pinfo)
+                                   struct wb_acct_info **pinfo)
 {
        struct rpc_pipe_client *samr_pipe;
        struct policy_handle dom_pol;
-       struct acct_info *info = NULL;
+       struct wb_acct_info *info = NULL;
        uint32_t num_info = 0;
        TALLOC_CTX *tmp_ctx;
        NTSTATUS status, result;
@@ -323,15 +241,13 @@ static NTSTATUS sam_query_user(struct winbindd_domain *domain,
        ZERO_STRUCT(dom_pol);
 
        /* Paranoia check */
-       if (!sid_check_is_in_our_domain(user_sid)) {
+       if (!sid_check_is_in_our_sam(user_sid)) {
                return NT_STATUS_NO_SUCH_USER;
        }
 
-       if (user_info) {
-               user_info->homedir = NULL;
-               user_info->shell = NULL;
-               user_info->primary_gid = (gid_t) -1;
-       }
+       user_info->homedir = NULL;
+       user_info->shell = NULL;
+       user_info->primary_gid = (gid_t) -1;
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
@@ -450,7 +366,7 @@ static NTSTATUS sam_lookup_groupmem(struct winbindd_domain *domain,
        }
 
        if (pnum_names) {
-               pnum_names = 0;
+               *pnum_names = 0;
        }
 
        tmp_ctx = talloc_stackframe();
@@ -509,8 +425,8 @@ done:
 /* List all domain groups */
 static NTSTATUS builtin_enum_dom_groups(struct winbindd_domain *domain,
                                TALLOC_CTX *mem_ctx,
-                               uint32 *num_entries,
-                               struct acct_info **info)
+                               uint32_t *num_entries,
+                               struct wb_acct_info **info)
 {
        /* BUILTIN doesn't have domain groups */
        *num_entries = 0;
@@ -521,7 +437,7 @@ static NTSTATUS builtin_enum_dom_groups(struct winbindd_domain *domain,
 /* Query display info for a domain */
 static NTSTATUS builtin_query_user_list(struct winbindd_domain *domain,
                                TALLOC_CTX *mem_ctx,
-                               uint32 *num_entries,
+                               uint32_t *num_entries,
                                struct wbint_userinfo **info)
 {
        /* We don't have users */
@@ -556,11 +472,11 @@ static NTSTATUS builtin_trusted_domains(struct winbindd_domain *domain,
 static NTSTATUS sam_enum_local_groups(struct winbindd_domain *domain,
                                      TALLOC_CTX *mem_ctx,
                                      uint32_t *pnum_info,
-                                     struct acct_info **pinfo)
+                                     struct wb_acct_info **pinfo)
 {
        struct rpc_pipe_client *samr_pipe;
        struct policy_handle dom_pol;
-       struct acct_info *info = NULL;
+       struct wb_acct_info *info = NULL;
        uint32_t num_info = 0;
        TALLOC_CTX *tmp_ctx;
        NTSTATUS status, result;
@@ -696,7 +612,9 @@ static NTSTATUS sam_sid_to_name(struct winbindd_domain *domain,
 
        /* Paranoia check */
        if (!sid_check_is_in_builtin(sid) &&
-           !sid_check_is_in_our_domain(sid) &&
+           !sid_check_is_builtin(sid) &&
+           !sid_check_is_in_our_sam(sid) &&
+           !sid_check_is_our_sam(sid) &&
            !sid_check_is_in_unix_users(sid) &&
            !sid_check_is_unix_users(sid) &&
            !sid_check_is_in_unix_groups(sid) &&
@@ -752,7 +670,7 @@ done:
 static NTSTATUS sam_rids_to_names(struct winbindd_domain *domain,
                                  TALLOC_CTX *mem_ctx,
                                  const struct dom_sid *domain_sid,
-                                 uint32 *rids,
+                                 uint32_t *rids,
                                  size_t num_rids,
                                  char **pdomain_name,
                                  char ***pnames,
@@ -773,7 +691,7 @@ static NTSTATUS sam_rids_to_names(struct winbindd_domain *domain,
 
        /* Paranoia check */
        if (!sid_check_is_builtin(domain_sid) &&
-           !sid_check_is_domain(domain_sid) &&
+           !sid_check_is_our_sam(domain_sid) &&
            !sid_check_is_unix_users(domain_sid) &&
            !sid_check_is_unix_groups(domain_sid) &&
            !sid_check_is_in_wellknown_domain(domain_sid)) {
@@ -859,7 +777,7 @@ static NTSTATUS sam_lockout_policy(struct winbindd_domain *domain,
        status = dcerpc_samr_QueryDomainInfo(b,
                                             mem_ctx,
                                             &dom_pol,
-                                            12,
+                                            DomainLockoutInformation,
                                             &info,
                                             &result);
        if (!NT_STATUS_IS_OK(status)) {
@@ -911,7 +829,7 @@ static NTSTATUS sam_password_policy(struct winbindd_domain *domain,
        status = dcerpc_samr_QueryDomainInfo(b,
                                             mem_ctx,
                                             &dom_pol,
-                                            1,
+                                            DomainPasswordInformation,
                                             &info,
                                             &result);
        if (!NT_STATUS_IS_OK(status)) {