Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Get Domain Name

Posted on 2000-03-31
5
Medium Priority
?
269 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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. …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

719 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