Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Primary Domain Controller Name and local workstation Name??

Primary Domain Controller Name and local workstation Name??

Scheduled Pinned Locked Moved C / C++ / MFC
designjsonquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    umarcool
    wrote on last edited by
    #1

    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.

    K 1 Reply Last reply
    0
    • U umarcool

      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.

      K Offline
      K Offline
      kasturi_haribabu
      wrote on last edited by
      #2

      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_

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups