Solved

COM+ : display friendly UserName

Posted on 2001-08-28
4
374 Views
Last Modified: 2007-12-19
Hi,

   Env : Windows 2000, COM+, C++

   I wrote a COM component using VC++ and put it in my COM+ application.
   Now, i am trying to get the username ( client ) who access this COM component.
   This following code get the User ID ( user's network account id Ex : "Domainname\SSubbiah").

STDMETHODIMP CTest::GetUserName(VARIANT *pbstrUserName)
{
     CComPtr<ISecurityCallContext> pSecurityCallContext;
     if (SUCCEEDED(::CoGetCallContext(__uuidof(ISecurityCallContext), (void **) &pSecurityCallContext)))
    {
            pSecurityCallContext->get_Item(L"DirectCaller", pbstrUserName);
            CComQIPtr<ISecurityIdentityColl> m_pSecurityIdentityColl = (*pbstrUserName).pdispVal;
            m_pSecurityIdentityColl->get_Item(L"AccountName", pbstrUserName);
     }
     return S_OK;
}

    Now, i am trying to get the display friendly user name ( "Subbiah, Sankar" ). If i am not in
    COM+, i can get the user name by calling "GetUserNameEx" method. But i dont know how
     to get the display friendly name if my component is in COM+. Anyone done this before ???

Thanks,
Sankar S.


0
Comment
Question by:sankars98
  • 2
4 Comments
 
LVL 4

Expert Comment

by:jtwine100697
ID: 6433562
Forgive my asking, but what can you not use the standard Win32 API?

-=- James.
0
 
LVL 9

Accepted Solution

by:
ShaunWilde earned 150 total points
ID: 6433720
is TranslateName what you are looking for - it gives the impression it can take domain\user to something more friendly
0
 
LVL 1

Author Comment

by:sankars98
ID: 6433978

 Thanks for the responses.

 James, standard Win32 API call will not
 return the client's id if the COM object is running
 inside COM+ application. Instead, it will return
 the local ( server machine's ) account id. So, i cant
 use it.

 ShaunWilde, Thanks alot. TranslateName method did that
 trick.

 Thanks Again.
 
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 6434423
That's right...  Forgot about that.  I should have remembered from all the times we had problems with services (our services often exposed a custom COM interface) that were configured to run under Local System or some other account.

Glad you got your answer...

-=- James.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

809 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