Solved

COM+ : display friendly UserName

Posted on 2001-08-28
4
373 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
Comment Utility
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
Comment Utility
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
Comment Utility

 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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now