fosters
asked on
Get Domain Name
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()functio n.
Which according to MSDN returns the domain name.
When run on NT Dr. Watson kicks in...
Current code below...
CString PCInformation::GetDomainNa me()
{
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)ReferencedDomainNam e;
}
Any help would be much appreciated..
Cheers
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()functio
Which according to MSDN returns the domain name.
When run on NT Dr. Watson kicks in...
Current code below...
CString PCInformation::GetDomainNa
{
LPTSTR lpAccountName= " ";
DWORD cbAccountName = 20;
PSID Sid;
LPDWORD cbSid;
LPTSTR ReferencedDomainName = " ";
LPDWORD cbReferencedDomainName;
PSID_NAME_USE peUse;
GetUserName(lpAccountName,
LookupAccountName(NULL, lpAccountName, Sid, cbSid, ReferencedDomainName, cbReferencedDomainName, peUse);
return (LPSTR)ReferencedDomainNam
}
Any help would be much appreciated..
Cheers
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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::GetUserAndD omainName( char *,unsigned long *,char *,unsigned long *)" (?GetUserAndDomainName@PCI nformation @@QAEHPADP AK01@Z)
Any ideas....
PCInformation.obj : error LNK2001: unresolved external symbol "public: int __thiscall PCInformation::GetUserAndD
Any ideas....
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?
ASKER
I did indeed forget to stick PCInformation:: in.
Cheers for your help
Cheers for your help
http://support.microsoft.com/support/kb/articles/Q155/6/98.ASP