Solved

How do I display String SID?

Posted on 2008-06-23
5
494 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
Comment Utility
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
Comment Utility
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
Comment Utility
Also make sure function returned nonzero value, maybe sid value is invalid.
0
 

Author Comment

by:mycuti08
Comment Utility
>>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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
This is an explanation of a simple data model to help parse a JSON feed
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

743 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

8 Experts available now in Live!

Get 1:1 Help Now