Solved

How do I display String SID?

Posted on 2008-06-23
5
495 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help to convert powershell script into a gui 9 169
parse convert xml feed to text (python) 2 81
Why isn't object file created? 6 57
Query Syntax 17 33
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

776 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