Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Get Domain Name

Posted on 2000-03-31
5
Medium Priority
?
275 Views
Last Modified: 2013-11-20
Hi

I wish to get the name of the Domain,  the workstation the programme is running, is on.

My Program is written in Visual C++ 5, using the MFC AppWizard.

I have tried using GetUserName() to get user ID for the LookUpAccountName()function.
Which according to MSDN returns the domain name.

When run on NT Dr. Watson kicks in...

Current code below...


CString PCInformation::GetDomainName()
{
      LPTSTR lpAccountName= " ";       
      DWORD cbAccountName = 20;
      PSID Sid;
        LPDWORD cbSid;        
      LPTSTR ReferencedDomainName = " ";
        LPDWORD cbReferencedDomainName;
             PSID_NAME_USE peUse;

      GetUserName(lpAccountName, &cbAccountName);
      
LookupAccountName(NULL, lpAccountName, Sid, cbSid, ReferencedDomainName, cbReferencedDomainName, peUse);

      return (LPSTR)ReferencedDomainName;

}

Any help would be much appreciated..

Cheers
0
Comment
Question by:fosters
  • 3
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 400 total points
ID: 2675100
HOWTO: Retrieve Current User and Domain Names on Windows NT
http://support.microsoft.com/support/kb/articles/Q111/5/44.ASP
0
 
LVL 23

Expert Comment

by:chensu
ID: 2675102
HOWTO: Retrieve Current User and Domain Names on Windows 95 and Windows 98
http://support.microsoft.com/support/kb/articles/Q155/6/98.ASP
0
 

Author Comment

by:fosters
ID: 2676043
I have enetered the code and got it to complile. But I keep getting the following link error.

PCInformation.obj : error LNK2001: unresolved external symbol "public: int __thiscall PCInformation::GetUserAndDomainName(char *,unsigned long *,char *,unsigned long *)" (?GetUserAndDomainName@PCInformation@@QAEHPADPAK01@Z)


Any ideas....
0
 
LVL 23

Expert Comment

by:chensu
ID: 2676397
It looks like that you declare GetUserAndDomainName as a public member function of your PCInformation class. But how do you define it? Do you forget to put PCInformation:: right before GetUserAndDomainName?
0
 

Author Comment

by:fosters
ID: 2676435
I did indeed forget to stick PCInformation:: in.

Cheers for your help
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month12 days, 4 hours left to enroll

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question