InvokeHelper() throws Access is denied exception - c++

Community, I have quite interesting and in the same time heavy problem.
I have VB .NET application + Service + C++ application. C++ application generates some data and makes callbacks using InvokeHelper() method:
InvokeHelper(0x60030000, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
eventType, eventValue);
The first parameter is the dispid of method which should be called. Strange approach, but this is not my code and I can not change this way.
In service I have method marked by dispid attribute to get this callback from C++ application.
<DispId(&H60030000)>
Public Sub ServerEvent(ByVal vEventType As Integer, ByVal vEventValue As Object)
RaiseEvent ControlPanelStateChange(vEventType, vEventValue)
End Sub
This code works correctly if I logged on as admin. But if windows user has not administrator permissions, right after calling InvokeHelper() method the next exception occurs:
First-chance exception at 0x75B7C42D (KernelBase.dll) in application.exe: 0x80070005: Access is denied
Do you have any ideas? I have played with DCOM permissions, but result is the same.
Any help would be fantastic!

The solution of the problem is:
DCOMCNFG, right click on the My Computer and select properties -> COM Securities tab -> Access Permissions -> click Edit Defaults and add Network Service to it and give it Allow local access permission. Do the same for < Machine_name >\Users.
Then -> Launch and Activation Permissions, click Edit Defaults and add Network Service to it and give it Local launch and Local Activation permission. Do the same for < Machine_name >\Users.

Related

Unable to Retrieve IMFAudioPolicy from Media Session

I have developed Win32 app based heavily on the MF_ProtectedPlayback sample here. I'm using 4 cplayer objects at a time. It works for what I need it to do.
However, I am trying to group the sessions, so that they are controlled by one volume control in control panel, as described in docs here.
My problem is that I cannot get the IMFAudioPolicy (MR_AUDIO_POLICY_SERVICE) from the session. As in the sample, I'm using the MFCreateAudioRendererActivate() method to create the renderers. Again, this all works fine. I have no problem getting other interfaces back from the session, like IMFSimpleAudioVolume.
I get the following errors:
-onecore\com\combase\dcomrem\call.cxx(4907)\combase.dll!75EB0755: (caller: 75E931D8) ReturnHr(3) tid(7e60) 80040155 Interface not registered
-Exception thrown at 0x773DA892 (KernelBase.dll) in MyApp.exe: 0x80040155: Interface not registered.
Relevant code:
HRESULT CPlayer::OnTopologyReady(IMFMediaEvent* pEvent)
{
\\ works fine
MFGetService(
m_pSession,
MR_VIDEO_RENDER_SERVICE,
__uuidof(IMFVideoDisplayControl),
(void**)&m_pVideoDisplay
);
\\ works fine
MFGetService(
m_pSession,
MR_POLICY_VOLUME_SERVICE,
__uuidof(IMFSimpleAudioVolume),
(void**)&m_pSimpleVolume
);
// winrt errors, returns null
MFGetService(
m_pSession,
MR_AUDIO_POLICY_SERVICE,
__uuidof(IMFAudioPolicy),
(void**)&m_pAudioPolicy
);
HRESULT hr = StartPlayback();
return S_OK;
}
What am I missing? Any ideas why this interface is not available? Thanks...
-jerry
edit: so it appears that what I want to do may not be possible. This problem is related to the protected processes created in PMP. Still investigating...

WinAPI ReportEvent - component not installed

I've implemented a simple function to log on event viewer from my application. However, I'm getting the following message every time I log something, regardless the error level:
The description for Event ID 0 from source MyAppEvents cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
I'm not an expert on Event log, actually, this is the first time I'm using it in C++, and the documentation is confusing and misleading...
Here is the method I've implemented, to encapsulate event log calls:
HANDLE source = NULL;
void app_log(std::string m, WORD level) {
std::wstring msg_temp (m.begin(), m.end());
LPCWSTR msg = msg_temp.c_str();
std::wstring name(L"MyAppEvents");
if (source == NULL)
source = RegisterEventSource(NULL, name.c_str());
if (source) {
if (!ReportEvent(source, level, 0, 0, NULL, 1, 0, &msg, NULL))
std::cerr << "Error when logging";
}
else
std::cerr << "Error when logging";
}
I have an installer for my app, built with WIX (this installer creates the key needed to log on event viewer - subkey of Application) and it runs smoothly. However, I didn't understand that message, and also don't know how to attach my installed app to the event log - I'm actually not even sure if this is the problem, or if it is maybe one of the parameters I'm passing as NULL or 0.
This message appears also when I debug (without installing, but with the "application subkey" manually created).
Could you help me?
I can't use C++ managed code...
There is nothing wrong with your logging code. The warning message simply means that you have not properly registered the MyAppEvents event source in the Registry. This is documented on MSDN:
RegisterEventSource function:
pSourceName [in]
The name of the event source whose handle is to be retrieved. The source name must be a subkey of a log under the Eventlog registry key. Note that the Security log is for system use only.
Event Sources:
The structure of the event sources is as follows:
HKEY_LOCAL_MACHINE
SYSTEM
CurrentControlSet
Services
EventLog
Application
AppName
Security
System
DriverName
CustomLog
AppName
...
Each event source contains information (such as a message file) specific to the software that will be logging the events
...
An application can use the Application log without adding a new event source to the registry. If the application calls RegisterEventSource and passes a source name that cannot be found in the registry, the event-logging service uses the Application log by default. However, because there are no message files, the Event Viewer cannot map any event identifiers or event categories to a description string, and will display an error. For this reason, you should add a unique event source to the registry for your application and specify a message file.
It is not enough to just create the MyAppEvents subkey, you also have to point it to the message files for your app. If you store your event log categories and event messages as resources of your app executable, the subkey can register the executable itself as the message files.

Custom Windows Authentication Package Logon Failed

I have developed custom authentication package that I would like to use for interactive logon. It creates the access token in the LsaApUserLogon function.
When I call LsaUserLogon from an application I can enumerate new user sessions, but when I used it for logon (also I have created a custom credential provider) I can see in Windows Event log that I was successfully logged in and then logged out.
When I select my specific Credential and try to logon, it enters into LsaApLogonUser API of my Authentication Package. If I check log file, LsaApLogonUser return STATUS_SUCCESS. But Windows is not logged on. After leaving LsaAPLogonUser, LSA calls LsaApLogonTerminated API and back LogonUI.
When I prepared the TokenInformation I got LookupPrivilegeValueW failed for the SeInteractiveLogonRight. I don't know if this is important for logon.
LsaApLogonUser(...){
......
// NetUserGetInfo
// AllocateLocallyUniqueId (LogonId)
err = GetTokenInformationv2(pdi?pdi->DomainControllerName:NULL,wszDomain,wszUser,&LocalTokenInformation,LogonId);
err = g_pSec->CreateLogonSession(LogonId);
if(ProfileBuffer)
{
*ProfileBuffer=NULL;
*ProfileBufferLength=0;
}
(*TokenInformationType)=LsaTokenInformationV2;
(*TokenInformation)=LocalTokenInformation;
return STATUS_SUCCESS;
}
GetTokenInformationv2(...){
....
....
// Call LsaEnumerateAccountRights
// check LookupPrivilegeValueW // It failed for "SeInteractiveLogonRight"
//
return STATUS_SUCCESS;
}
Is ProfileBuffer important for logon? I don't know why LSA cannot logon.
The documentation does not say that the profile buffer can be set to NULL and it seems that it is indeed mandatory. The OP reports that allocating and returning a profile buffer (just a single byte was enough) resolved the problem.
The error when attempting to retrieve a LUID for SeInteractiveLogonRight was not relevant; the user's logon rights do not need to be included in the TOKEN_PRIVILEGES structure, so no LUID is needed, and as documented, the LookupPrivilegeValue function only accepts privileges:
The LookupPrivilegeValue function supports only the privileges specified in the Defined Privileges section of Winnt.h.
(Note that the relevant section of winnt.h only contains definitions for SeXxxPrivilege; the definitions for SeXxxLogonRight are in ntsecapi.h.)

Getting error on Content Editor after upgrading to Sitecore 8

I have done an upgrade from Sitecore 7.5 to Sitecore 8, And I am getting an error when trying to Access the Content Editor.
Server Error in '/' Application.
Value cannot be null.
Parameter name: fieldNameTranslator
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: fieldNameTranslator
Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin
and location of the exception can be identified using the exception
stack trace below.
[ArgumentNullException: Value cannot be null.
Parameter name: fieldNameTranslator]
Sitecore.ContentSearch.Linq.Solr.SolrIndexParameters..ctor(IIndexValueFormatter >valueFormatter, IFieldQueryTranslatorMap`1 fieldQueryTranslators, >FieldNameTranslator fieldNameTranslator, IExecutionContext[] executionContexts, >IFieldMapReaders fieldMap, Boolean convertQueryDatesToUtc) +310
Sitecore.ContentSearch.SolrProvider.LinqToSolrIndex`1..ctor(SolrSearchContext >context, IExecutionContext[] executionContexts) +192
Sitecore.ContentSearch.SolrProvider.SolrSearchContext.GetQueryable(IExecutionCo>ntext[] executionContexts) +83
Sitecore.ContentTesting.ContentSearch.TestingSearch.GetRunningTests() +637
Sitecore.ContentTesting.Data.SitecoreContentTestStore.GetActiveTests(DataUri >hostItemDataUri, String searchText) +252
Sitecore.ContentTesting.Pipelines.GetContentEditorWarnings.GetContentTestingWar>nings.Process(GetContentEditorWarningsArgs args) +247
(Object , Object[] ) +141
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +365
Sitecore.Shell.Applications.ContentManager.Editor.GetWarnings(Boolean >hasSections) +271
Sitecore.Shell.Applications.ContentManager.Editor.Render(RenderContentEditorArg>s args, Control parent) +178
Sitecore.Shell.Applications.ContentManager.ContentEditorForm.RenderEditor(Item >item, Item root, Control parent, Boolean showEditor) +231
Sitecore.Shell.Applications.ContentManager.ContentEditorForm.UpdateEditor(Item >folder, Item root, Boolean showEditor) +374
Sitecore.Shell.Applications.ContentManager.ContentEditorForm.Update() +411
Sitecore.Shell.Applications.ContentManager.ContentEditorForm.OnPreRendered(Even>tArgs e) +212
This is assuming that you already disabled all the Lucene configuration under your App_Config > Include folder and read the Sitecore Search Scaling Guide chapter 3, if not yet, please do so.
Now, the problem relies on your Global.asax, replace the:
Inherits="Sitecore.Web.Application"
To:
Inherits="Sitecore.ContentSearch.SolrProvider.CastleWindsorIntegration.WindsorApplication"
This is assuming again that your dependency injection is the CastleWindsor and all the essential DLLs for CastleWindors were deployed in your web instance (Website > bin folder)
These are:
SolrNet.dll
Microsoft.Practices.ServiceLocation.dll
Castle.Facilities.SolrNetIntegration.dll
Sitecore.ContentSearch.SolrProvider.CastleWindsorIntegration.dll
Alternatively, there are other four (4) DI framework you can check if CastleWindor is not the dependency injection of your project, and the descriptive details of these DI can be found in the Sitecore Search Scaling Guide.
Once the verification and setup is completed, reload your Sitecore instance and it should load properly. Cheers!
Edited: You may also want to check the SOLR support package DLL version against your current instance version. I experienced the issue several times this week and the root cause always boils down to DLL version discrepancies.
There is something we needed to do with this. Have you changed from Lucene to Solr. It's was in the Solr.config we needed to change some values, although I thought this bug had been fixed. Take a look at
http://blog.horizontalintegration.com/2015/01/21/sitecore-8-solr-configuration-and-setup/
https://born4joy.wordpress.com/2015/09/03/installation-and-configuration-of-solr-for-sitecore-8/

System.Web.Services.Protocols.SoapException The application encountered an unhandled system exception. From binary file

I have a project in .net that accesses a GP Web Services, it works fine. However when I generate a dll from this project and try to run the same from a different project using this dll, I get the following message: System.Web.Services.Protocols.SoapException The application encountered an unhandled system exception. Contact your system administrator for details.
I think it might be a permissions issue or something like this but I'm not sure, this is how the client is created:
WSHttpBinding binding = new WSHttpBinding();
EndpointAddress ep = new EndpointAddress(new Uri("..."), new UpnEndpointIdentity("..."), (AddressHeader[])null);
DynamicsGPClient wsDynamicsGP = new DynamicsGPClient(binding, ep);