Click here to Skip to main content
15,039,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.
I'm trying to use socket(...) function and get WSAEACCES=Permission denied
error right away.
Also, I run my VS under administrator login, however the following code says I am NOT an admin:

--------------------------------------------------
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup;
// Initialize SID.
if( !AllocateAndInitializeSid( &NtAuthority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&AdministratorsGroup))
{
AfxMessageBox("Initializing SID Failed.");

return;
}
BOOL IsInAdminGroup = FALSE;
if( !CheckTokenMembership( NULL,
AdministratorsGroup,
&IsInAdminGroup ))
{
// Error occurred.
IsInAdminGroup = FALSE;
}
// Free SID and return.
FreeSid(AdministratorsGroup);

------------------------------------
IsInAdminGroup is FALSE.

Function GetUserName(...) returns my login.

Any suggestions? (Worked on XP)
Posted
Updated 28-Apr-10 0:31am
v3

You could check if "Run as administrator" works.
   
>>You could check if "Run as administrator" works.
Running as an administrator works on exe files.
Hom am I supposed to do that in VS? I am developing the app and can't debug it this way. Is there a way to debug under admin privilege. Also, may be there is a way to use sockets bypassing that layer of admin, so it would work from any account?
   
Check your Windows firewall. Turn it off. Your program can be blocked. Also try to turn off User Account Control.
   
>>Check your Windows firewall. Turn it off. Your program can be blocked. Also try to turn off User Account Control.

Firewall is off. I will try to disable UAC. However I am looking to use socket without worrying about type of a user account. I guess that's not possible in new Windows architecture(
   
It seems I need to tweak linker's manifest options.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900