Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I display String SID?

Posted on 2008-06-23
5
Medium Priority
?
511 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
[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
5 Comments
 
LVL 86

Assisted Solution

by:jkr
jkr earned 200 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 400 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 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

715 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