* Unix SMB/CIFS implementation.
* Helper routines for net
* Copyright (C) Volker Lendecke 2006
+ * Copyright (C) Kai Blin 2008
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
return false;
}
- if (is_zero_addr(&pdc_ss)) {
+ if (is_zero_addr((struct sockaddr *)&pdc_ss)) {
return false;
}
if (!get_pdc_ip(domain_name, server_ss)) {
return false;
}
- if (is_zero_addr(server_ss)) {
+ if (is_zero_addr((struct sockaddr *)server_ss)) {
return false;
}
return NULL;
}
- asprintf(&prompt, "Enter %s's password:", user);
- if (!prompt) {
+ if (asprintf(&prompt, "Enter %s's password:", user) == -1) {
return NULL;
}
d_printf("%s\n", table[i].usage);
}
}
+
+const char *net_share_type_str(int num_type)
+{
+ switch(num_type) {
+ case 0: return "Disk";
+ case 1: return "Print";
+ case 2: return "Dev";
+ case 3: return "IPC";
+ default: return "Unknown";
+ }
+}
+
+NTSTATUS net_scan_dc(struct net_context *c,
+ struct cli_state *cli,
+ struct net_dc_info *dc_info)
+{
+ TALLOC_CTX *mem_ctx = talloc_tos();
+ struct rpc_pipe_client *dssetup_pipe = NULL;
+ union dssetup_DsRoleInfo info;
+ NTSTATUS status;
+
+ ZERO_STRUCTP(dc_info);
+
+ status = cli_rpc_pipe_open_noauth(cli, &ndr_table_dssetup.syntax_id,
+ &dssetup_pipe);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ status = rpccli_dssetup_DsRoleGetPrimaryDomainInformation(dssetup_pipe, mem_ctx,
+ DS_ROLE_BASIC_INFORMATION,
+ &info,
+ NULL);
+ TALLOC_FREE(dssetup_pipe);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ dc_info->is_dc = (info.basic.role & (DS_ROLE_PRIMARY_DC|DS_ROLE_BACKUP_DC));
+ dc_info->is_pdc = (info.basic.role & DS_ROLE_PRIMARY_DC);
+ dc_info->is_ad = (info.basic.flags & DS_ROLE_PRIMARY_DS_RUNNING);
+ dc_info->is_mixed_mode = (info.basic.flags & DS_ROLE_PRIMARY_DS_MIXED_MODE);
+ dc_info->netbios_domain_name = talloc_strdup(mem_ctx, info.basic.domain);
+ dc_info->dns_domain_name = talloc_strdup(mem_ctx, info.basic.dns_domain);
+ dc_info->forest_name = talloc_strdup(mem_ctx, info.basic.forest);
+
+ return NT_STATUS_OK;
+}