s3:idmap: remove the set_mapping method from the idmap API
[amitay/samba.git] / source3 / winbindd / idmap_adex / idmap_adex.c
index 23ab843e95d89470e74e1691edce22783ac78c3f..5e55df357e6b311ea277dd74f69267d717dd1917 100644 (file)
  */
 
 #include "includes.h"
+#include "ads.h"
 #include "idmap_adex.h"
+#include "nss_info.h"
+#include "secrets.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_IDMAP
@@ -44,7 +47,7 @@ static NTSTATUS _idmap_adex_init(struct idmap_domain *dom,
        ADS_STRUCT *ads = NULL;
        ADS_STATUS status;
        static NTSTATUS init_status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
-       DOM_SID domain_sid;
+       struct dom_sid domain_sid;
        fstring dcname;
        struct sockaddr_storage ip;
        struct likewise_cell *lwcell;
@@ -159,6 +162,11 @@ static NTSTATUS _idmap_adex_get_sid_from_id(struct
        NTSTATUS nt_status;
         struct likewise_cell *cell;
 
+       /* initialize the status to avoid suprise */
+       for (i = 0; ids[i]; i++) {
+               ids[i]->status = ID_UNKNOWN;
+       }
+       
        nt_status = _idmap_adex_init(dom, NULL);
        if (!NT_STATUS_IS_OK(nt_status))
                return nt_status;
@@ -207,6 +215,11 @@ static NTSTATUS _idmap_adex_get_id_from_sid(struct
        NTSTATUS nt_status;
         struct likewise_cell *cell;
 
+       /* initialize the status to avoid suprise */
+       for (i = 0; ids[i]; i++) {
+               ids[i]->status = ID_UNKNOWN;
+       }
+       
        nt_status = _idmap_adex_init(dom, NULL);
        if (!NT_STATUS_IS_OK(nt_status))
                return nt_status;
@@ -240,41 +253,6 @@ static NTSTATUS _idmap_adex_get_id_from_sid(struct
        return NT_STATUS_OK;
 }
 
-/**********************************************************************
- *********************************************************************/
-
-static NTSTATUS _idmap_adex_set_mapping(struct
-                                           idmap_domain
-                                           *dom, const struct
-                                           id_map *map)
-{
-       DEBUG(0, ("_idmap_adex_set_mapping: not implemented\n"));
-       return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/**********************************************************************
- *********************************************************************/
-
-static NTSTATUS _idmap_adex_remove_mapping(struct
-                                              idmap_domain
-                                              *dom, const
-                                              struct
-                                              id_map
-                                              *map)
-{
-       DEBUG(0, ("_idmap_adex_remove_mapping: not implemented\n"));
-       return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/**********************************************************************
- *********************************************************************/
-
-static NTSTATUS _idmap_adex_dump(struct idmap_domain
-                                    *dom, struct id_map **maps, int *num_map)
-{
-       return NT_STATUS_NOT_IMPLEMENTED;
-}
-
 /**********************************************************************
  *********************************************************************/
 
@@ -304,12 +282,13 @@ static NTSTATUS _nss_adex_init(struct nss_domain_entry
 
 static NTSTATUS _nss_adex_get_info(struct
                                      nss_domain_entry *e,
-                                     const DOM_SID * sid,
+                                     const struct dom_sid * sid,
                                      TALLOC_CTX * ctx,
                                      ADS_STRUCT * ads,
                                      LDAPMessage * msg,
-                                     char **homedir,
-                                     char **shell, char **gecos, gid_t * p_gid)
+                                     const char **homedir,
+                                     const char **shell,
+                                     const char **gecos, gid_t * p_gid)
 {
        NTSTATUS nt_status;
         struct likewise_cell *cell;
@@ -329,9 +308,9 @@ static NTSTATUS _nss_adex_get_info(struct
 /**********************************************************************
  *********************************************************************/
 
-static NTSTATUS _nss_adex_map_to_alias(TALLOC_CTX * mem_ctx, const char
-                                         *domain, const char
-                                         *name, char **alias)
+static NTSTATUS _nss_adex_map_to_alias(TALLOC_CTX * mem_ctx,
+                                      struct nss_domain_entry *e,
+                                      const char *name, char **alias)
 {
        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
         struct likewise_cell *cell = NULL;
@@ -344,7 +323,7 @@ static NTSTATUS _nss_adex_map_to_alias(TALLOC_CTX * mem_ctx, const char
                BAIL_ON_NTSTATUS_ERROR(nt_status);
        }
 
-       nt_status = cell->provider->map_to_alias(mem_ctx, domain,
+       nt_status = cell->provider->map_to_alias(mem_ctx, e->domain,
                                                 name, alias);
 
        /* go ahead and allow the cache mgr to mark this in
@@ -360,9 +339,9 @@ done:
 /**********************************************************************
  *********************************************************************/
 
-static NTSTATUS _nss_adex_map_from_alias(TALLOC_CTX * mem_ctx, const char
-                                           *domain, const char
-                                           *alias, char **name)
+static NTSTATUS _nss_adex_map_from_alias(TALLOC_CTX * mem_ctx,
+                                        struct nss_domain_entry *e,
+                                        const char *alias, char **name)
 {
        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
         struct likewise_cell *cell = NULL;
@@ -376,7 +355,7 @@ static NTSTATUS _nss_adex_map_from_alias(TALLOC_CTX * mem_ctx, const char
        }
 
 
-       nt_status = cell->provider->map_from_alias(mem_ctx, domain,
+       nt_status = cell->provider->map_from_alias(mem_ctx, e->domain,
                                                   alias, name);
 
        /* go ahead and allow the cache mgr to mark this in
@@ -405,9 +384,6 @@ static struct idmap_methods adex_idmap_methods = {
        .init             = _idmap_adex_init,
        .unixids_to_sids  = _idmap_adex_get_sid_from_id,
        .sids_to_unixids  = _idmap_adex_get_id_from_sid,
-       .set_mapping      = _idmap_adex_set_mapping,
-       .remove_mapping   = _idmap_adex_remove_mapping,
-       .dump_data        = _idmap_adex_dump,
        .close_fn         = _idmap_adex_close
 };
 static struct nss_info_methods adex_nss_methods = {
@@ -454,7 +430,7 @@ NTSTATUS idmap_adex_init(void)
        return NT_STATUS_OK;
 }
 
-NTSTATUS nss_info_adex_init(void)
+static NTSTATUS nss_info_adex_init(void)
 {
        return idmap_adex_init();
 }