Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 514
  • Last Modified:

How do I display String SID?

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
mycuti08
Asked:
mycuti08
4 Solutions
 
jkrCommented:
What is the return value of the call? And if it is FALSE, what does 'GetLastError()' report?
0
 
LordOfPortsCommented:
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
 
Andrew_LvovCommented:
Also make sure function returned nonzero value, maybe sid value is invalid.
0
 
mycuti08Author Commented:
>>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
 
mycuti08Author Commented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now