Solved

COM+ : display friendly UserName

Posted on 2001-08-28
4
376 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

713 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