PDA

Click to See Complete Forum and Search --> : Domain Name?


vb_dba
Jun 20th, 2002, 11:08 AM
How can I return the Domain Name of the network I'm connected to? I've looked for an API for this, but can't seem to find one.

Thanks

jim mcnamara
Jun 20th, 2002, 12:11 PM
Check out GetNetworkParams() -- I did this from memory so check it :D

long cbRequired;
char *buf;
FIXED_INFO * Info;
long result = GetNetworkParams(NULL, cbRequired);
if(cbRequired){
buf = (char*) malloc(cbRequired);
if(GetNetWorkParams(buf,cbRequired) ) == ERROR_SUCCESS) {
Info = (FIXED_INFO*) buf;
printf("Domain name = ",%s,Info->DomainName);
}
}

vb_dba
Jun 20th, 2002, 12:26 PM
Do I need to declare the FIXED_INFO datatype? I get an undeclared identifier error when trying to declare Info as that type.

jim mcnamara
Jun 20th, 2002, 02:24 PM
#include <Iptypes.h>



typedef struct {
char HostName [MAX_HOSTNAME_LEN + 4];
char DomainName [MAX_DOMAIN_NAME_LEN + 4];
PIP_ADDR_STRING CurrentDnsServer;
IP_ADDR_STRING DnsServerList;
UINT NodeType;
char ScopeId [MAX_SCOPE_ID_LEN + 4];
UINT EnableRouting;
UINT EnableProxy;
UINT EnableDns;
} FIXED_INFO, *PFIXED_INFO;
Members
HostName[MAX_HOSTNAME_LEN + 4]
Specifies the host name for the local computer.
DomainName[MAX_DOMAIN_NAME_LEN + 4]
Specifies the domain in which the local computer is registered.
CurrentDnsServer
Specifies the current DNS server.
DnsServerList
Specifies the set of DNS servers used by the local computer.
NodeType
Specifies whether the local computer uses dynamic host configuration protocol (DHCP).
ScopeId[MAX_SCOPE_ID_LEN + 4]
Specifies the DHCP scope name.
EnableRouting
Specifies whether routing is enabled on the local computer.
EnableProxy
Specifies whether the local computer is acting as an ARP proxy.
EnableDns
Specifies whether DNS is enabled on the local computer.

jim mcnamara
Jun 20th, 2002, 02:27 PM
You can declare
PFIXED_INFO Info;