Solved

COM+ : display friendly UserName

Posted on 2001-08-28
4
378 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Suggested Solutions

Title # Comments Views Activity
convert char array to number in c 5 93
Setting nameservers after res_init fails doing res_query 2 139
object oriented programming comparison 5 94
Coding for the first time 9 103
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…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

752 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