Primary Domain Controller Name and local workstation Name??
-
Hi, I am looking for windows api for finding out that Whether a system is connected to Primary domain controller or its a local workstation? If i am logged on to a domain controller i would like to know the domain name? And if i am on a local machine then i would like to know about the computer name? I tried GetComputerName but it doesn't give the domain controller Domain name in case of domain. I want to somehow know if its on a domain or not?? Regards, UI.
-
Hi, I am looking for windows api for finding out that Whether a system is connected to Primary domain controller or its a local workstation? If i am logged on to a domain controller i would like to know the domain name? And if i am on a local machine then i would like to know about the computer name? I tried GetComputerName but it doesn't give the domain controller Domain name in case of domain. I want to somehow know if its on a domain or not?? Regards, UI.
Dear umar cool, Please find code for your question ....Thanks for giving me a good question to answer... Senior guys... Please forgive me if I wrote a stupid code.... int EnumAllComputers() { LPSERVER_INFO_101 pBuf = NULL; LPSERVER_INFO_101 pTmpBuf; DWORD dwLevel = 101; DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH; DWORD dwEntriesRead = 0; DWORD dwTotalEntries = 0; DWORD dwTotalCount = 0; DWORD dwServerType = SV_TYPE_SERVER; // all servers DWORD dwResumeHandle = 0; NET_API_STATUS nStatus; LPTSTR pszServerName = NULL; DWORD i; // // Call the NetServerEnum function to retrieve information // for all servers, specifying information level 101. // nStatus = NetServerEnum((LPCSTR)pszServerName, dwLevel, (LPBYTE *) &pBuf, dwPrefMaxLen, &dwEntriesRead, &dwTotalEntries, dwServerType, NULL, &dwResumeHandle); // // If the call succeeds, // if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA)) { if ((pTmpBuf = pBuf) != NULL) { // // Loop through the entries and // print the data for all server types. // for (i = 0; i < dwEntriesRead; i++) { assert(pTmpBuf != NULL); if (pTmpBuf == NULL) { fprintf(stderr, "An access violation has occurred\n"); break; } //printf("\tPlatform: %d\n", pTmpBuf->sv101_platform_id); wprintf(L"\tName: %s\n", pTmpBuf->sv101_name); //printf("\tVersion: %d.%d\n", // pTmpBuf->sv101_version_major, // pTmpBuf->sv101_version_minor); printf("\tType: %d", pTmpBuf->sv101_type); // // Check to see if the server is a domain controller; // if so, identify it as a PDC or a BDC. // /*SV_TYPE_WORKSTATION SV_TYPE_SERVER SV_TYPE_SQLSERVER SV_TYPE_DOMAIN_CTRL SV_TYPE_DOMAIN_BAKCTRL SV_TYPE_TIME_SOURCE SV_TYPE_AFP SV_TYPE_NOVELL SV_TYPE_DOMAIN_MEMBER SV_TYPE_PRINTQ_SERVER SV_TYPE_DIALIN_SERVER SV_TYPE_