libnetjoin: add libnet_join_rollback().
authorGünther Deschner <gd@samba.org>
Thu, 5 Jun 2008 17:00:05 +0000 (19:00 +0200)
committerGünther Deschner <gd@samba.org>
Thu, 5 Jun 2008 17:34:30 +0000 (19:34 +0200)
This is required now if the join verify failed and we already
modified the local configuration.

Guenther

source/libnet/libnet_join.c

index 16dcc61afed3e8a3962459af7461eb0ae6b0d064..3678ff94989f119791ea715ea70e5a79e9971a72 100644 (file)
@@ -1733,6 +1733,35 @@ static WERROR libnet_DomainJoin(TALLOC_CTX *mem_ctx,
 /****************************************************************
 ****************************************************************/
 
+WERROR libnet_join_rollback(TALLOC_CTX *mem_ctx,
+                           struct libnet_JoinCtx *r)
+{
+       WERROR werr;
+       struct libnet_UnjoinCtx *u = NULL;
+
+       werr = libnet_init_UnjoinCtx(mem_ctx, &u);
+       if (!W_ERROR_IS_OK(werr)) {
+               return werr;
+       }
+
+       u->in.debug             = r->in.debug;
+       u->in.dc_name           = r->in.dc_name;
+       u->in.domain_name       = r->in.domain_name;
+       u->in.admin_account     = r->in.admin_account;
+       u->in.admin_password    = r->in.admin_password;
+       u->in.modify_config     = r->in.modify_config;
+       u->in.unjoin_flags      = WKSSVC_JOIN_FLAGS_JOIN_TYPE |
+                                 WKSSVC_JOIN_FLAGS_ACCOUNT_DELETE;
+
+       werr = libnet_Unjoin(mem_ctx, u);
+       TALLOC_FREE(u);
+
+       return werr;
+}
+
+/****************************************************************
+****************************************************************/
+
 WERROR libnet_Join(TALLOC_CTX *mem_ctx,
                   struct libnet_JoinCtx *r)
 {
@@ -1762,7 +1791,7 @@ WERROR libnet_Join(TALLOC_CTX *mem_ctx,
        if (r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE) {
                werr = libnet_join_post_verify(mem_ctx, r);
                if (!W_ERROR_IS_OK(werr)) {
-                       goto done;
+                       libnet_join_rollback(mem_ctx, r);
                }
        }