Click here to Skip to main content
15,908,931 members
Home / Discussions / COM
   

COM

 
QuestionHow to check if a COM DLL was generated from given source code ? [modified] Pin
GuimaSun8-Apr-08 7:20
GuimaSun8-Apr-08 7:20 
Questionhow to defined a defaultvalue interface-function in idl file? Pin
huangdingjun7-Apr-08 17:12
huangdingjun7-Apr-08 17:12 
QuestionHow to add VC++ 6.0 dlls to ASP.NET web application?( through Add ref) Pin
Prabakar3-Apr-08 23:58
Prabakar3-Apr-08 23:58 
GeneralCOM/ATL Event problem [modified] Pin
knuttermutter3-Apr-08 0:21
knuttermutter3-Apr-08 0:21 
GeneralEvents from C# to COM dll (C++) Pin
SteinarAa2-Apr-08 2:58
SteinarAa2-Apr-08 2:58 
GeneralRe: Events from C# to COM dll (C++) Pin
Randor 14-Apr-08 17:10
professional Randor 14-Apr-08 17:10 
QuestionMaking COM introp and calling the method from C# project Pin
Mushtaque Nizamani30-Mar-08 6:06
Mushtaque Nizamani30-Mar-08 6:06 
QuestionDCOM security issue Pin
tony_Udz27-Mar-08 17:46
tony_Udz27-Mar-08 17:46 
Hello,

Using the below code, i am trying to authorize user "Valid\User1" to create COM object of "TestServiceSecurity" from a remote machine.
This code is working fine that is it not throwing any kind of error but still it is not giving autorization to "User1".

Can anybody help me with this?

Thanks in advance.

*************************************************************************************************************************


BOOL bDaclPresent = FALSE;
BOOL bDaclDefaulted = FALSE;
DWORD dwError = 0;
DWORD dwSize = 0;
EXPLICIT_ACCESS ea;
PACL pacl = NULL;
PACL pNewAcl = NULL;
PSECURITY_DESCRIPTOR psd;
SC_HANDLE schManager = NULL;
SC_HANDLE schService = NULL;
SECURITY_DESCRIPTOR sd = {0};
SERVICE_STATUS_PROCESS ssp;
DWORD dwBytesNeeded;
PSID sid;


schManager = OpenSCManager(0, 0, SC_MANAGER_CONNECT);

if (schManager == NULL)
DisplayError(GetLastError(), TEXT("OpenSCManager"));


schService = OpenService(schManager , "TestServiceSecurity",SC_MANAGER_ALL_ACCESS);
if (schService == NULL)
DisplayError(GetLastError(), TEXT("OpenService"));



psd = (PSECURITY_DESCRIPTOR)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, dwSize);

// Get the current security descriptor.
BOOL bResult = QueryServiceObjectSecurity(schService, DACL_SECURITY_INFORMATION, psd, 0, &dwSize);
if (!bResult)
{
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER){
psd = (PSECURITY_DESCRIPTOR)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, dwSize);
if (psd == NULL){
DisplayError(0, TEXT("HeapAlloc"));
// note HeapAlloc does not support GetLastError()
}

bResult = QueryServiceObjectSecurity(schService, DACL_SECURITY_INFORMATION, psd, dwSize, &dwSize);
if(!bResult)
DisplayError(GetLastError(), TEXT("QueryServiceObjectSecurity"));

}
else
DisplayError(GetLastError(), TEXT("QueryServiceObjectSecurity"));
}


// Get the DACL.
bResult = GetSecurityDescriptorDacl(psd, &bDaclPresent, &pacl, &bDaclDefaulted);
if (!bResult)
DisplayError(GetLastError(), TEXT("GetSecurityDescriptorDacl"));

// Build the ACE.
BuildExplicitAccessWithName(&ea, TEXT("Valid\\User1"), COM_RIGHTS_EXECUTE,
SET_ACCESS, NO_INHERITANCE);


dwError = SetEntriesInAcl(1, &ea, pacl, &pNewAcl);

if (dwError != ERROR_SUCCESS)
DisplayError(dwError, TEXT("SetEntriesInAcl"));

//AddAccessAllowedACEToACL(
bool bIsValidACL = IsValidAcl(pacl);

// Initialize a NEW Security Descriptor.
bResult = InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
if (!bResult)
DisplayError(GetLastError(), TEXT("InitializeSecurityDescriptor"));

// Set the new DACL in the Security Descriptor.
bResult = SetSecurityDescriptorDacl(&sd, TRUE, /*pNewAcl*/NULL, FALSE);
if (!bResult)
DisplayError(GetLastError(), TEXT("SetSecurityDescriptorDacl"));


// Set the new DACL for the service object.
bResult = SetServiceObjectSecurity(schService, DACL_SECURITY_INFORMATION, &sd);
if (!bResult)
DisplayError(GetLastError(), TEXT("SetServiceObjectSecurity"));


// Close the handles.
bResult = CloseServiceHandle(schManager);
if (!bResult)
DisplayError(GetLastError(), TEXT("CloseServiceHandle"));

bResult = CloseServiceHandle(schService);
if (!bResult)
DisplayError(GetLastError(), TEXT("CloseServiceHandle"));

// Free buffers.
LocalFree((HLOCAL)pNewAcl);
HeapFree(GetProcessHeap(), 0, (LPVOID)psd);



*************************************************************************************************************************
GeneralSetWindowPos in COM application Pin
sheetal_0626-Mar-08 23:38
sheetal_0626-Mar-08 23:38 
GeneralCOM Communication Pin
HakunaMatada25-Mar-08 1:25
HakunaMatada25-Mar-08 1:25 
GeneralRe: COM Communication Pin
Mike Dimmick30-Mar-08 12:58
Mike Dimmick30-Mar-08 12:58 
GeneralRe: COM Communication Pin
HakunaMatada30-Mar-08 19:12
HakunaMatada30-Mar-08 19:12 
GeneralBSTR variable Pin
vc++_fragrance24-Mar-08 19:48
vc++_fragrance24-Mar-08 19:48 
GeneralRe: BSTR variable Pin
User 21559725-Mar-08 1:24
User 21559725-Mar-08 1:24 
GeneralRe: BSTR variable Pin
CPallini26-Mar-08 1:07
mveCPallini26-Mar-08 1:07 
GeneralC# class library Pin
pnpfriend24-Mar-08 9:24
pnpfriend24-Mar-08 9:24 
GeneralRe: C# class library Pin
Scott Dorman25-Mar-08 15:37
professionalScott Dorman25-Mar-08 15:37 
GeneralCalling .NET component from VB. [modified] Pin
SPanicker*23-Mar-08 21:38
SPanicker*23-Mar-08 21:38 
GeneralRe: Calling .NET component from VB. Pin
Vi23-Apr-08 20:13
Vi23-Apr-08 20:13 
QuestionHow to Rreference COM object(tlb file) in VC++ Pin
Jahnson K21-Mar-08 10:05
Jahnson K21-Mar-08 10:05 
AnswerRe: How to Rreference COM object(tlb file) in VC++ Pin
User 21559722-Mar-08 3:02
User 21559722-Mar-08 3:02 
GeneralRe: How to Rreference COM object(tlb file) in VC++ Pin
Jahnson K22-Mar-08 11:31
Jahnson K22-Mar-08 11:31 
GeneralRe: How to Rreference COM object(tlb file) in VC++ Pin
User 21559723-Mar-08 2:28
User 21559723-Mar-08 2:28 
AnswerRe: How to Rreference COM object(tlb file) in VC++ Pin
pnpfriend24-Mar-08 9:34
pnpfriend24-Mar-08 9:34 
GeneralRe: How to Rreference COM object(tlb file) in VC++ Pin
Jahnson K25-Mar-08 7:35
Jahnson K25-Mar-08 7:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.