/* Send request */
- if (winbindd_request_response(WINBINDD_GETDCNAME, &request,
+ if (winbindd_request_response(NULL, WINBINDD_GETDCNAME, &request,
&response) != NSS_STATUS_SUCCESS) {
d_fprintf(stderr, "Could not get dc name for %s\n",domain_name);
return false;
WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");
if (wbc_status == WBC_ERR_AUTH_ERROR) {
- d_fprintf(stderr, "error code was %s (0x%x)\n",
- error->nt_string, error->nt_status);
+ d_fprintf(stderr, "wbcCheckTrustCredentials(%s): error code was %s (0x%x)\n",
+ domain_name, error->nt_string, error->nt_status);
wbcFreeMemory(error);
}
if (!WBC_ERROR_IS_OK(wbc_status)) {
WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");
if (wbc_status == WBC_ERR_AUTH_ERROR) {
- d_fprintf(stderr, "error code was %s (0x%x)\n",
- error->nt_string, error->nt_status);
+ d_fprintf(stderr, "wbcChangeTrustCredentials(%s): error code was %s (0x%x)\n",
+ domain_name, error->nt_string, error->nt_status);
wbcFreeMemory(error);
}
if (!WBC_ERROR_IS_OK(wbc_status)) {
/* Check DC connection */
-static bool wbinfo_ping_dc(void)
+static bool wbinfo_ping_dc(const char *domain)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
struct wbcAuthErrorInfo *error = NULL;
char *dcname = NULL;
- wbc_status = wbcPingDc2(NULL, &error, &dcname);
+ const char *domain_name;
- d_printf("checking the NETLOGON dc connection to \"%s\" %s\n",
+ if (domain) {
+ domain_name = domain;
+ } else {
+ domain_name = get_winbind_domain();
+ }
+
+ wbc_status = wbcPingDc2(domain_name, &error, &dcname);
+
+ d_printf("checking the NETLOGON for domain[%s] dc connection to \"%s\" %s\n",
+ domain_name ? domain_name : "",
dcname ? dcname : "",
WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");
wbcFreeMemory(dcname);
if (wbc_status == WBC_ERR_AUTH_ERROR) {
- d_fprintf(stderr, "error code was %s (0x%x)\n",
- error->nt_string, error->nt_status);
+ d_fprintf(stderr, "wbcPingDc2(%s): error code was %s (0x%x)\n",
+ domain_name, error->nt_string, error->nt_status);
wbcFreeMemory(error);
return false;
}
return true;
}
+static bool wbinfo_xids_to_sids(const char *arg)
+{
+ fstring idstr;
+ struct wbcUnixId *xids = NULL;
+ struct wbcDomainSid *sids;
+ wbcErr wbc_status;
+ int num_xids = 0;
+ const char *p;
+ int i;
+
+ p = arg;
+
+ while (next_token(&p, idstr, LIST_SEP, sizeof(idstr))) {
+ xids = talloc_realloc(talloc_tos(), xids, struct wbcUnixId,
+ num_xids+1);
+ if (xids == NULL) {
+ d_fprintf(stderr, "talloc failed\n");
+ return false;
+ }
+
+ switch (idstr[0]) {
+ case 'u':
+ xids[num_xids] = (struct wbcUnixId) {
+ .type = WBC_ID_TYPE_UID,
+ .id.uid = atoi(&idstr[1])
+ };
+ break;
+ case 'g':
+ xids[num_xids] = (struct wbcUnixId) {
+ .type = WBC_ID_TYPE_GID,
+ .id.gid = atoi(&idstr[1])
+ };
+ break;
+ default:
+ d_fprintf(stderr, "%s is an invalid id\n", idstr);
+ TALLOC_FREE(xids);
+ return false;
+ }
+ num_xids += 1;
+ }
+
+ sids = talloc_array(talloc_tos(), struct wbcDomainSid, num_xids);
+ if (sids == NULL) {
+ d_fprintf(stderr, "talloc failed\n");
+ TALLOC_FREE(xids);
+ return false;
+ }
+
+ wbc_status = wbcUnixIdsToSids(xids, num_xids, sids);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_fprintf(stderr, "wbcUnixIdsToSids failed: %s\n",
+ wbcErrorString(wbc_status));
+ TALLOC_FREE(sids);
+ TALLOC_FREE(xids);
+ return false;
+ }
+
+ for (i=0; i<num_xids; i++) {
+ char str[WBC_SID_STRING_BUFLEN];
+ wbcSidToStringBuf(&sids[i], str, sizeof(str));
+ d_printf("%s\n", str);
+ }
+
+ return true;
+}
+
static bool wbinfo_allocate_uid(void)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
}
wbc_status = wbcLookupRids(&dinfo->sid, num_rids, rids,
- (const char **)&domain_name, &names, &types);
+ &p, &names, &types);
if (!WBC_ERROR_IS_OK(wbc_status)) {
d_printf("winbind_lookup_rids failed: %s\n",
wbcErrorString(wbc_status));
goto done;
}
+ domain_name = discard_const_p(char, p);
d_printf("Domain: %s\n", domain_name);
for (i=0; i<num_rids; i++) {
if (error) {
d_fprintf(stderr,
- "error code was %s (0x%x)\nerror message was: %s\n",
- error->nt_string,
+ "wbcLogonUser(%s): error code was %s (0x%x)\n"
+ "error message was: %s\n",
+ params.username, error->nt_string,
error->nt_status,
error->display_string);
}
get_winbind_netbios_name(),
get_winbind_domain());
- if (!SMBNTLMv2encrypt(NULL, name_user, name_domain, pass,
+ if (pass != NULL &&
+ !SMBNTLMv2encrypt(NULL, name_user, name_domain, pass,
&server_chal,
&names_blob,
&lm, &nt, NULL, NULL)) {
if (wbc_status == WBC_ERR_AUTH_ERROR) {
d_fprintf(stderr,
- "error code was %s (0x%x)\nerror message was: %s\n",
+ "wbcAuthenticateUserEx(%s%c%s): error code was "
+ "%s (0x%x, authoritative=%"PRIu8")\n"
+ "error message was: %s\n",
+ name_domain,
+ winbind_separator(),
+ name_user,
err->nt_string,
err->nt_status,
+ err->authoritative,
err->display_string);
wbcFreeMemory(err);
} else if (WBC_ERROR_IS_OK(wbc_status)) {
/* Authenticate a user with a plaintext password */
-static bool wbinfo_pam_logon(char *username)
+static bool wbinfo_pam_logon(char *username, bool verbose)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
struct wbcLogonUserParams params;
+ struct wbcLogonUserInfo *info = NULL;
struct wbcAuthErrorInfo *error = NULL;
char *s = NULL;
char *p = NULL;
return false;
}
- wbc_status = wbcLogonUser(¶ms, NULL, &error, NULL);
+ wbc_status = wbcLogonUser(¶ms, &info, &error, NULL);
+
+ if (verbose && (info != NULL)) {
+ struct wbcAuthUserInfo *i = info->info;
+ uint32_t j;
+
+ if (i->account_name != NULL) {
+ d_printf("account_name: %s\n", i->account_name);
+ }
+ if (i->user_principal != NULL) {
+ d_printf("user_principal: %s\n", i->user_principal);
+ }
+ if (i->full_name != NULL) {
+ d_printf("full_name: %s\n", i->full_name);
+ }
+ if (i->domain_name != NULL) {
+ d_printf("domain_name: %s\n", i->domain_name);
+ }
+ if (i->dns_domain_name != NULL) {
+ d_printf("dns_domain_name: %s\n", i->dns_domain_name);
+ }
+ if (i->logon_server != NULL) {
+ d_printf("logon_server: %s\n", i->logon_server);
+ }
+ if (i->logon_script != NULL) {
+ d_printf("logon_script: %s\n", i->logon_script);
+ }
+ if (i->profile_path != NULL) {
+ d_printf("profile_path: %s\n", i->profile_path);
+ }
+ if (i->home_directory != NULL) {
+ d_printf("home_directory: %s\n", i->home_directory);
+ }
+ if (i->home_drive != NULL) {
+ d_printf("home_drive: %s\n", i->home_drive);
+ }
+
+ d_printf("sids:");
+
+ for (j=0; j<i->num_sids; j++) {
+ char buf[WBC_SID_STRING_BUFLEN];
+ wbcSidToStringBuf(&i->sids[j].sid, buf, sizeof(buf));
+ d_printf(" %s", buf);
+ }
+ d_printf("\n");
+
+ wbcFreeMemory(info);
+ info = NULL;
+ }
wbcFreeMemory(params.blobs);
if (!WBC_ERROR_IS_OK(wbc_status) && (error != NULL)) {
d_fprintf(stderr,
- "error code was %s (0x%x)\nerror message was: %s\n",
+ "wbcLogonUser(%s): error code was %s (0x%x)\n"
+ "error message was: %s\n",
+ params.username,
error->nt_string,
(int)error->nt_status,
error->display_string);
request.flags |= WBFLAG_PAM_AFS_TOKEN;
- result = winbindd_request_response(WINBINDD_PAM_AUTH, &request,
+ result = winbindd_request_response(NULL, WINBINDD_PAM_AUTH, &request,
&response);
/* Display response */
OPT_REMOVE_UID_MAPPING,
OPT_REMOVE_GID_MAPPING,
OPT_SIDS_TO_XIDS,
+ OPT_XIDS_TO_SIDS,
OPT_SEPARATOR,
OPT_LIST_ALL_DOMAINS,
OPT_LIST_OWN_DOMAIN,
OPT_CHANGE_USER_PASSWORD,
OPT_CCACHE_SAVE,
OPT_SID_TO_FULLNAME,
+ OPT_NTLMV1,
OPT_NTLMV2,
OPT_PAM_LOGON,
OPT_LOGOFF,
OPT_KRB5CCNAME
};
-int main(int argc, char **argv, char **envp)
+int main(int argc, const char **argv, char **envp)
{
int opt;
TALLOC_CTX *frame = talloc_stackframe();
int int_subarg = -1;
int result = 1;
bool verbose = false;
- bool use_ntlmv2 = false;
+ bool use_ntlmv2 = true;
bool use_lanman = false;
char *logoff_user = getenv("USER");
int logoff_uid = geteuid();
{ "remove-gid-mapping", 0, POPT_ARG_STRING, &string_arg, OPT_REMOVE_GID_MAPPING, "Remove gid to sid mapping in idmap", "GID,SID" },
{ "sids-to-unix-ids", 0, POPT_ARG_STRING, &string_arg,
OPT_SIDS_TO_XIDS, "Translate SIDs to Unix IDs", "Sid-List" },
+ { "unix-ids-to-sids", 0, POPT_ARG_STRING, &string_arg,
+ OPT_XIDS_TO_SIDS, "Translate Unix IDs to SIDs",
+ "ID-List (u<num> g<num>)" },
{ "check-secret", 't', POPT_ARG_NONE, 0, 't', "Check shared secret" },
{ "change-secret", 'c', POPT_ARG_NONE, 0, 'c', "Change shared secret" },
{ "ping-dc", 'P', POPT_ARG_NONE, 0, 'P',
{ "separator", 0, POPT_ARG_NONE, 0, OPT_SEPARATOR, "Get the active winbind separator", NULL },
{ "verbose", 0, POPT_ARG_NONE, 0, OPT_VERBOSE, "Print additional information per command", NULL },
{ "change-user-password", 0, POPT_ARG_STRING, &string_arg, OPT_CHANGE_USER_PASSWORD, "Change the password for a user", NULL },
+ { "ntlmv1", 0, POPT_ARG_NONE, 0, OPT_NTLMV1,
+ "Use NTLMv1 cryptography for user authentication", NULL},
{ "ntlmv2", 0, POPT_ARG_NONE, 0, OPT_NTLMV2, "Use NTLMv2 cryptography for user authentication", NULL},
{ "lanman", 0, POPT_ARG_NONE, 0, OPT_LANMAN, "Use lanman cryptography for user authentication", NULL},
POPT_COMMON_VERSION
};
/* Samba client initialisation */
- load_case_tables();
+ smb_init_locale();
/* Parse options */
- pc = poptGetContext("wbinfo", argc, (const char **)argv,
+ pc = poptGetContext("wbinfo", argc, argv,
long_options, 0);
/* Parse command line options */
case OPT_VERBOSE:
verbose = true;
break;
- case OPT_NTLMV2:
- use_ntlmv2 = true;
+ case OPT_NTLMV1:
+ use_ntlmv2 = false;
break;
case OPT_LANMAN:
use_lanman = true;
goto done;
}
break;
+ case OPT_XIDS_TO_SIDS:
+ if (!wbinfo_xids_to_sids(string_arg)) {
+ d_fprintf(stderr, "wbinfo_xids_to_sids "
+ "failed\n");
+ goto done;
+ }
+ break;
case 't':
if (!wbinfo_check_secret(opt_domain_name)) {
d_fprintf(stderr, "Could not check secret\n");
}
break;
case 'P':
- if (!wbinfo_ping_dc()) {
+ if (!wbinfo_ping_dc(opt_domain_name)) {
goto done;
}
break;
break;
}
case OPT_PAM_LOGON:
- if (!wbinfo_pam_logon(string_arg)) {
+ if (!wbinfo_pam_logon(string_arg, verbose)) {
d_fprintf(stderr, "pam_logon failed for %s\n",
string_arg);
goto done;