n.out.types = &types;
status = dcerpc_samr_LookupNames_r(b, mem_ctx, &n);
- if (NT_STATUS_IS_OK(status)) {
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ if (NT_STATUS_IS_OK(n.out.result)) {
rid = n.out.rids->ids[0];
} else {
- return status;
+ return n.out.result;
}
r.in.domain_handle = handle;
printf("OpenUser(%s) failed - %s\n", name, nt_errstr(status));
return status;
}
+ if (!NT_STATUS_IS_OK(r.out.result)) {
+ printf("OpenUser(%s) failed - %s\n", name, nt_errstr(r.out.result));
+ return r.out.result;
+ }
d.in.user_handle = &user_handle;
d.out.user_handle = &user_handle;
if (!NT_STATUS_IS_OK(status)) {
return status;
}
+ if (!NT_STATUS_IS_OK(d.out.result)) {
+ return d.out.result;
+ }
return NT_STATUS_OK;
}
printf("samr_Connect failed - %s\n", errstr);
return NULL;
}
+ if (!NT_STATUS_IS_OK(c.out.result)) {
+ const char *errstr = nt_errstr(c.out.result);
+ printf("samr_Connect failed - %s\n", errstr);
+ return NULL;
+ }
printf("Opening domain %s\n", domain);
printf("LookupDomain failed - %s\n", nt_errstr(status));
goto failed;
}
+ if (!NT_STATUS_IS_OK(l.out.result)) {
+ printf("LookupDomain failed - %s\n", nt_errstr(l.out.result));
+ goto failed;
+ }
talloc_steal(join, *l.out.sid);
join->dom_sid = *l.out.sid;
printf("OpenDomain failed - %s\n", nt_errstr(status));
goto failed;
}
+ if (!NT_STATUS_IS_OK(o.out.result)) {
+ printf("OpenDomain failed - %s\n", nt_errstr(o.out.result));
+ goto failed;
+ }
printf("Creating account %s\n", username);
r.out.rid = &rid;
status = dcerpc_samr_CreateUser2_r(b, join, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("CreateUser2 failed - %s\n", nt_errstr(status));
+ goto failed;
+ }
- if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
+ if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_USER_EXISTS)) {
status = DeleteUser_byname(b, join, &domain_handle, name.string);
if (NT_STATUS_IS_OK(status)) {
goto again;
}
}
- if (!NT_STATUS_IS_OK(status)) {
- printf("CreateUser2 failed - %s\n", nt_errstr(status));
+ if (!NT_STATUS_IS_OK(r.out.result)) {
+ printf("CreateUser2 failed - %s\n", nt_errstr(r.out.result));
goto failed;
}
pwp.out.info = &info;
status = dcerpc_samr_GetUserPwInfo_r(b, join, &pwp);
- if (NT_STATUS_IS_OK(status)) {
+ if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(pwp.out.result)) {
policy_min_pw_len = pwp.out.info->min_password_length;
}
printf("SetUserInfo failed - %s\n", nt_errstr(status));
goto failed;
}
+ if (!NT_STATUS_IS_OK(s.out.result)) {
+ printf("SetUserInfo failed - %s\n", nt_errstr(s.out.result));
+ goto failed;
+ }
ZERO_STRUCT(u);
s.in.user_handle = &join->user_handle;
printf("SetUserInfo failed - %s\n", nt_errstr(status));
goto failed;
}
+ if (!NT_STATUS_IS_OK(s.out.result)) {
+ printf("SetUserInfo failed - %s\n", nt_errstr(s.out.result));
+ goto failed;
+ }
if (random_password) {
*random_password = random_pw;
if (!NT_STATUS_IS_OK(status)) {
printf("SetUserInfo (non-critical) failed - %s\n", nt_errstr(status));
}
+ if (!NT_STATUS_IS_OK(s.out.result)) {
+ printf("SetUserInfo (non-critical) failed - %s\n", nt_errstr(s.out.result));
+ }
*machine_credentials = cli_credentials_init(tj);
cli_credentials_set_conf(*machine_credentials, tctx->lp_ctx);
/* Delete machine account */
status = dcerpc_samr_DeleteUser_r(join->p->binding_handle, join, &d);
if (!NT_STATUS_IS_OK(status)) {
+ printf("DeleteUser failed\n");
+ }
+ if (!NT_STATUS_IS_OK(d.out.result)) {
printf("Delete of machine account %s failed\n",
join->netbios_name);
} else {