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
Solved

How do I display String SID?

Posted on 2008-06-23
5
496 Views
Last Modified: 2013-12-14
I used ConvertSidToStringSid to convert a Sid to a string SID. The problem is when I displayed the string SID using wprintf, I saw only a bunch of question marks "?????" displayed?
How do I display it appropriately?

The code snippet is:
TCHAR sidstring[254];
ConvertSidToStringSid(sid, (LPWSTR*)sidstring);
wprintf(L"%s", sidstring);

Thanks,
0
Comment
Question by:mycuti08
5 Comments
 
LVL 86

Assisted Solution

by:jkr
jkr earned 50 total points
ID: 21849658
What is the return value of the call? And if it is FALSE, what does 'GetLastError()' report?
0
 
LVL 19

Assisted Solution

by:LordOfPorts
LordOfPorts earned 100 total points
ID: 21849789
The second parameter of the ConvertSidToStringSid http://msdn.microsoft.com/en-us/library/aa376399(VS.85).aspx should be of type LPTSTR* instead of LPWSTR* as in your code however this should not matter if you project is UNICODE.

wprintf requires that _UNICODE is defined, so might want to make sure that you have both:

#define UNICODE
#define _UNICODE

Try using the _tprintf instead:

_tprintf(TEXT("%s"), sidstring);

Try also setting debug flags for each of the lines and check the values of the variables line by line.
0
 
LVL 1

Assisted Solution

by:Andrew_Lvov
Andrew_Lvov earned 50 total points
ID: 21853932
Also make sure function returned nonzero value, maybe sid value is invalid.
0
 

Author Comment

by:mycuti08
ID: 21898725
>>What is the return value of the call?
>>Also make sure function returned nonzero value, maybe sid value is invalid.
the return value of the call is > 0, so no error.

>>Try using the _tprintf instead:
I tried that and the result was the same

Any other thought, please?
Thanks
0
 

Accepted Solution

by:
mycuti08 earned 0 total points
ID: 21898763
I found the workaround using Microsoft example that replace ConvertSIDsoStringSID
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.WIN32COM.v10.en/secauthz/security/converting_a_binary_sid_to_string_format_in_c__.htm

It allows me to print out the correct string.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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.

840 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