Solved

COM+ : display friendly UserName

Posted on 2001-08-28
4
375 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

829 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