Visual C++ question

Y

yellowblueyellow

Hi All,

I am creating a class library project for VC++ in VS 2005. On
compilation, the following error is returned

error C2664: 'LookupAccountNameW' : cannot convert parameter 1 from
'char *' to 'LPCWSTR'
the line of concern is :

if ( ! LookupAccountName( argv[1], argv[2], userSid, &sidSize, refDom,
&domSize, &sidUse ) )
err( "LAN()", gle, false );

I think the problem lies in the fact that the .h file has a main
function which is as follows

int main( int argc, char *argv[] )
{
if ( argc != 3 )
{
puts( "Usage: lsa_lear <system name> <account name>" );
puts( "Enumerates privileges for the named account on the named
machine." );
puts( "<system name> is the machine where the lookup will
execute." );
puts( "<account name> is the account to examine, e.g. \"FOO\\felixk
\" or \"Administrators\"." );
return 1;
}


// open the policy object on the target computer

static SECURITY_QUALITY_OF_SERVICE sqos = { sizeof
SECURITY_QUALITY_OF_SERVICE, SecurityImpersonation,
SECURITY_DYNAMIC_TRACKING, FALSE };
static LSA_OBJECT_ATTRIBUTES lsaOA = { sizeof LSA_OBJECT_ATTRIBUTES,
NULL, NULL, 0, NULL, &sqos };
NTSTATUS nts;
LSA_HANDLE polHandle;
LsaUnicodeString systemName;

systemName = argv[1];

nts = LsaOpenPolicy( systemName, &lsaOA, GENERIC_READ |
GENERIC_EXECUTE, &polHandle );
err( "LOP()", nts );

// translate the account name to a RID plus associated domain SID

SID *userSid;
char refDom[MAX_PATH];
SID_NAME_USE sidUse;
DWORD sidSize, domSize;
const char *acctTypeString;

userSid = (SID *) malloc( MAX_PATH );
sidSize = domSize = MAX_PATH;

if ( ! LookupAccountName( argv[1], argv[2], userSid, &sidSize,
refDom, &domSize, &sidUse ) )
err( "LAN()", gle, false );

acctTypeString = NULL;
switch ( sidUse )
{
case SidTypeAlias:
case SidTypeUser:
case SidTypeGroup:
case SidTypeWellKnownGroup:
break;
case SidTypeDomain:
if ( acctTypeString == NULL )
acctTypeString = " domain";
// fall-through
case SidTypeInvalid:
if ( acctTypeString == NULL )
acctTypeString = "n invalid";
// fall-through
case SidTypeUnknown:
if ( acctTypeString == NULL )
acctTypeString = "n unknown";
// fall-through
case SidTypeDeletedAccount:
if ( acctTypeString == NULL )
acctTypeString = " deleted";
printf( "Don't know how to handle a%s account.\n",
acctTypeString );
return 1;
}

LsaUnicodeString *userRights;
ULONG count;

userRights = NULL;
count = 0;
nts = LsaEnumerateAccountRights( polHandle, userSid,
(LSA_UNICODE_STRING **) &userRights, &count );
err( "LEAR()", nts );

DWORD i;
char *p;

printf( "%d privileges for user \"%s\" in domain \"%s\":\n", count,
argv[2], refDom );
for ( i = 0; i < count; ++ i )
{
p = (char *) userRights; // must free() later
printf( "priv %u: %s\n", i, p );
free( p );
}

LsaClose( polHandle );
free( userSid );

return 0;
}


Could someone assist me in getting rid of this problem.

Thanks
 
S

Sheng Jiang[MVP]

Ask it in the microsoft.public.vc.language group. This question has nothing
to do with .net framework.

--
Sheng Jiang
Microsoft MVP in VC++
Hi All,

I am creating a class library project for VC++ in VS 2005. On
compilation, the following error is returned

error C2664: 'LookupAccountNameW' : cannot convert parameter 1 from
'char *' to 'LPCWSTR'
the line of concern is :

if ( ! LookupAccountName( argv[1], argv[2], userSid, &sidSize, refDom,
&domSize, &sidUse ) )
err( "LAN()", gle, false );

I think the problem lies in the fact that the .h file has a main
function which is as follows

int main( int argc, char *argv[] )
{
if ( argc != 3 )
{
puts( "Usage: lsa_lear <system name> <account name>" );
puts( "Enumerates privileges for the named account on the named
machine." );
puts( "<system name> is the machine where the lookup will
execute." );
puts( "<account name> is the account to examine, e.g. \"FOO\\felixk
\" or \"Administrators\"." );
return 1;
}


// open the policy object on the target computer

static SECURITY_QUALITY_OF_SERVICE sqos = { sizeof
SECURITY_QUALITY_OF_SERVICE, SecurityImpersonation,
SECURITY_DYNAMIC_TRACKING, FALSE };
static LSA_OBJECT_ATTRIBUTES lsaOA = { sizeof LSA_OBJECT_ATTRIBUTES,
NULL, NULL, 0, NULL, &sqos };
NTSTATUS nts;
LSA_HANDLE polHandle;
LsaUnicodeString systemName;

systemName = argv[1];

nts = LsaOpenPolicy( systemName, &lsaOA, GENERIC_READ |
GENERIC_EXECUTE, &polHandle );
err( "LOP()", nts );

// translate the account name to a RID plus associated domain SID

SID *userSid;
char refDom[MAX_PATH];
SID_NAME_USE sidUse;
DWORD sidSize, domSize;
const char *acctTypeString;

userSid = (SID *) malloc( MAX_PATH );
sidSize = domSize = MAX_PATH;

if ( ! LookupAccountName( argv[1], argv[2], userSid, &sidSize,
refDom, &domSize, &sidUse ) )
err( "LAN()", gle, false );

acctTypeString = NULL;
switch ( sidUse )
{
case SidTypeAlias:
case SidTypeUser:
case SidTypeGroup:
case SidTypeWellKnownGroup:
break;
case SidTypeDomain:
if ( acctTypeString == NULL )
acctTypeString = " domain";
// fall-through
case SidTypeInvalid:
if ( acctTypeString == NULL )
acctTypeString = "n invalid";
// fall-through
case SidTypeUnknown:
if ( acctTypeString == NULL )
acctTypeString = "n unknown";
// fall-through
case SidTypeDeletedAccount:
if ( acctTypeString == NULL )
acctTypeString = " deleted";
printf( "Don't know how to handle a%s account.\n",
acctTypeString );
return 1;
}

LsaUnicodeString *userRights;
ULONG count;

userRights = NULL;
count = 0;
nts = LsaEnumerateAccountRights( polHandle, userSid,
(LSA_UNICODE_STRING **) &userRights, &count );
err( "LEAR()", nts );

DWORD i;
char *p;

printf( "%d privileges for user \"%s\" in domain \"%s\":\n", count,
argv[2], refDom );
for ( i = 0; i < count; ++ i )
{
p = (char *) userRights; // must free() later
printf( "priv %u: %s\n", i, p );
free( p );
}

LsaClose( polHandle );
free( userSid );

return 0;
}


Could someone assist me in getting rid of this problem.

Thanks
 
Y

yellowblueyellow

...never mind .... figured itout :D

actually it does have to do with the framework.

Ask it in the microsoft.public.vc.language group. This question has nothing
to do with .net framework.

--
Sheng Jiang



I am creating a class library project for VC++ in VS 2005. On
compilation, the following error is returned
error C2664: 'LookupAccountNameW' : cannot convert parameter 1 from
'char *' to 'LPCWSTR'
the line of concern is :
if ( ! LookupAccountName( argv[1], argv[2], userSid, &sidSize, refDom,
&domSize, &sidUse ) )
err( "LAN()", gle, false );
I think the problem lies in the fact that the .h file has a main
function which is as follows
int main( int argc, char *argv[] )
{
if ( argc != 3 )
{
puts( "Usage: lsa_lear <system name> <account name>" );
puts( "Enumerates privileges for the named account on the named
machine." );
puts( "<system name> is the machine where the lookup will
execute." );
puts( "<account name> is the account to examine, e.g. \"FOO\\felixk
\" or \"Administrators\"." );
return 1;
}
// open the policy object on the target computer
static SECURITY_QUALITY_OF_SERVICE sqos = { sizeof
SECURITY_QUALITY_OF_SERVICE, SecurityImpersonation,
SECURITY_DYNAMIC_TRACKING, FALSE };
static LSA_OBJECT_ATTRIBUTES lsaOA = { sizeof LSA_OBJECT_ATTRIBUTES,
NULL, NULL, 0, NULL, &sqos };
NTSTATUS nts;
LSA_HANDLE polHandle;
LsaUnicodeString systemName;
systemName = argv[1];
nts = LsaOpenPolicy( systemName, &lsaOA, GENERIC_READ |
GENERIC_EXECUTE, &polHandle );
err( "LOP()", nts );
// translate the account name to a RID plus associated domain SID
SID *userSid;
char refDom[MAX_PATH];
SID_NAME_USE sidUse;
DWORD sidSize, domSize;
const char *acctTypeString;
userSid = (SID *) malloc( MAX_PATH );
sidSize = domSize = MAX_PATH;
if ( ! LookupAccountName( argv[1], argv[2], userSid, &sidSize,
refDom, &domSize, &sidUse ) )
err( "LAN()", gle, false );
acctTypeString = NULL;
switch ( sidUse )
{
case SidTypeAlias:
case SidTypeUser:
case SidTypeGroup:
case SidTypeWellKnownGroup:
break;
case SidTypeDomain:
if ( acctTypeString == NULL )
acctTypeString = " domain";
// fall-through
case SidTypeInvalid:
if ( acctTypeString == NULL )
acctTypeString = "n invalid";
// fall-through
case SidTypeUnknown:
if ( acctTypeString == NULL )
acctTypeString = "n unknown";
// fall-through
case SidTypeDeletedAccount:
if ( acctTypeString == NULL )
acctTypeString = " deleted";
printf( "Don't know how to handle a%s account.\n",
acctTypeString );
return 1;
}
LsaUnicodeString *userRights;
ULONG count;
userRights = NULL;
count = 0;
nts = LsaEnumerateAccountRights( polHandle, userSid,
(LSA_UNICODE_STRING **) &userRights, &count );
err( "LEAR()", nts );
DWORD i;
char *p;
printf( "%d privileges for user \"%s\" in domain \"%s\":\n", count,
argv[2], refDom );
for ( i = 0; i < count; ++ i )
{
p = (char *) userRights; // must free() later
printf( "priv %u: %s\n", i, p );
free( p );
}

LsaClose( polHandle );
free( userSid );
return 0;
}
Could someone assist me in getting rid of this problem.
Thanks- Hide quoted text -

- Show quoted text -
 
L

Larry Smith

..never mind .... figured itout :D
actually it does have to do with the framework.

Based on what you posted it has nothing to do with .NET whatsoever. You
likely had the UNICODE and/or _UNICODE constants #defined.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top