The following is a log event generated by ActiveDirectory. I have an application that reads such logs and processes them. I want to make a test-application that will simulate active directory events and write similar logs to Windows event log.
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="SIMULATOR" />
<EventID Qualifiers="0">4769</EventID>
<Level>0</Level>
<Task>0</Task>
<Keywords>0xa0000000000000</Keywords>
<TimeCreated SystemTime="2014-02-03T10:52:20.000000000Z" />
<EventRecordID>35215</EventRecordID>
<Channel>Application</Channel>
<Computer>dev.local</Computer>
<Security />
</System>
<EventData>
<Data Name="TargetUserName">WIN2K8R2-PCX$</Data>
<Data Name="TargetDomainName">dev.local</Data>
<Data Name="TargetSid">S-1-5-21-527455857-2257904818-3601372424-1001</Data>
<Data Name="ServiceName">Administrator</Data>
<Data Name="ServiceSid">S-1-5-21-527455857-2257904818-3601372424-502</Data>
<Data Name="TicketOptions">0x40810010</Data>
<Data Name="Status">0x0</Data>
<Data Name="TicketEncryptionType">0x12</Data>
<Data Name="PreAuthType">2</Data>
<Data Name="IpAddress">84.1.24.45</Data>
<Data Name="IpPort">0</Data>
<Data Name="CertIssuerName" />
<Data Name="CertSerialNumber" />
<Data Name="CertThumbprint" />
</EventData>
Please note that are multiple Data elements inside EventData element!
If I use the following, I do get multiple data elements but how do specify the Name attribute of each Data element?
string [] eventLog = new string[] {"A", "S", "D"};
EventLog log = new EventLog {Source = "source"};
log.WriteEvent(eventInstance, eventLog);
On this article I found that I can use the manifest registered by ActiveDirectory by using EventDescriptor/EventProvider. But that doesn't write anything in event log.
I found active directory guids by following the steps given here . On my system the guids are as follows
Active Directory Domain Services: SAM {8E598056-8993-11D2-819E-0000F875A064}
Active Directory: Kerberos Client {BBA3ADD2-C229-4CDB-AE2B-57EB6966B0C4}
Active Directory: NetLogon {F33959B4-DBEC-11D2-895B-00C04F79AB69}
Here's one way
From the way I read it, you need to:
Use ManifestGenerator (EcManGen.exe) to create a manifest skeleton for your app.
Use the manifest to describe the data you want to persist.
Use ManifestCompiler (mc.exe) to compile the manifest, resulting in (among other things) a .cs and .rc file.
Use ResourceCompiler (rc.exe) to compile the .rc into a real resource (.res)
Use the C# Compiler (csc.exe) to compile the .cs and .res files into an assembly. (needs to use /unsafe)
Add the assembly to your project.
As an admin, run wevutil to add the manifest to the machine on which these logs will be logged.
Once all of this is done, you can use the EventProvider from the assembly or the regular EventProvider (with a custom EventDescriptor).
Related
I've been having an issue on an Umbraco 7.5.6 site hosted in an App Service on Azure where the indexes seem to be dropped after an unspecific amount of time.
We're storing information, including some custom fields, on published news articles in the External Examine index to query stories from the index. This is consumed by our client-facing search API.
Initially, we thought that this might be caused by Azure swapping servers so removed the {computerName} parameter from the path under ExamineSettings.config. However, that didn't appear to have any effect.
Our current index path is ~/App_Data/TEMP/ExamineIndexes/External/
The ExamineSettings.config file is as follows:
<Examine>
<ExamineIndexProviders>
<providers>
<add name="InternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"
supportUnpublished="true"
supportProtected="true"
analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>
<add name="InternalMemberIndexer" type="UmbracoExamine.UmbracoMemberIndexer, UmbracoExamine"
supportUnpublished="true"
supportProtected="true"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>
<!-- default external indexer, which excludes protected and unpublished pages-->
<add name="ExternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"/>
</providers>
</ExamineIndexProviders>
<ExamineSearchProviders defaultProvider="ExternalSearcher">
<providers>
<add name="InternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>
<add name="ExternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" />
<add name="InternalMemberSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" enableLeadingWildcard="true"/>
</providers>
</ExamineSearchProviders>
</Examine>
Due to the unpredictable nature of this issue, short of writing a WebJob to republish the articles on a regular basis, I'm unsure of what to try next.
First thing to do is update your examine config
The filesystem attached to web apps is actually a UNC share which can suffer from IO latency issues which in turn can cause Umbraco to flip out a little bit.
Try updating your ExamineSettings.config as per the following and add this to the indexer(s):
directoryFactory="Examine.LuceneEngine.Directories.SyncTempEnvDirectoryFactory,Examine"
The SyncTempEnvDirectoryFactory enables Examine to sync indexes
between the remote file system and the local environment temporary
storage directory, the indexes will be accessed from the temporary
storage directory. This setting is required due to the nature of
Lucene files and IO latency on Azure Web Apps.
This should take performance issues out of the equation.
Then, debugging
Indexing issues should be picked up in Umbraco's logs (some at Info level, some at Debug). If you're not already capturing Umbraco's logs then use something like Papertrail or Application Insights to collect the logs and see if you can identify what's causing the deletion (you may need to drop logging level to Debug to catch it).
N.B if you do push logs to an external service then wrap it in the Async/Parallel provider from Umbraco Core: here's an example config.
<log4net>
<root>
<priority value="Info"/>
<appender-ref ref="AsynchronousLog4NetAppender" />
</root>
<appender name="AsynchronousLog4NetAppender" type="Umbraco.Core.Logging.ParallelForwardingAppender,Umbraco.Core">
<appender-ref ref="PapertrailRemoteSyslogAppender"/>
</appender>
<appender name="PapertrailRemoteSyslogAppender" type="log4net.Appender.RemoteSyslogAppender">
<facility value="Local6" />
<identity value="%date{yyyy-MM-ddTHH:mm:ss.ffffffzzz} your-site-name %P{log4net:HostName}" />
<layout type="log4net.Layout.PatternLayout" value="%level - %message%newline" />
<remoteAddress value="logsN.papertrailapp.com" />
<remotePort value="XXXXX" />
</appender>
<!--Here you can change the way logging works for certain namespaces -->
<logger name="NHibernate">
<level value="WARN" />
</logger>
</log4net>
I'm trying to get Facebook to redirect back to my Unity application (running on android) after a call to https://facebook.com/v2.8/dialog/oauth. I've created a custom URL scheme in my android app like myApp://. However, when I attempt to send the OAuth request through to facebook, it tells me that the redirect_uri is not supported. I've tried to add my custom URL to my Facebook app's OAuth settings, but it says it is not a valid URL (which makes sense, as it's technically not).
The request:
var url = string.Format("https://facebook.com/v2.8/dialog/oauth?client_id={0}&response_type=token&redirect_uri={1}", "MYAPPID", "redfish%3A%2F%2Ffacebooklogin");
My app's AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:icon="#drawable/app_icon" android:label="#string/app_name">
<activity android:name=".MainActivity" android:label="#string/app_name" android:launchMode="singleTask" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="sensor">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="redfish" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
</application>
</manifest>
Code for catching the redirect in unity:
public class OnAcessToken : MonoBehaviour {
void OnAccessToken(string accessToken)
{
Debug.Log("Received access token: " + accessToken);
SceneManager.LoadScene("FileSelect");
}
}
The class OnAccessToken is hit using a custom library generated by the instructions at http://oferei.com/2013/06/serverless-instagram-authentication/.
What I'm asking is how to I get Facebook to allow my custom URL scheme as a valid redirect_uri? Or am I going about this the wrong way.
Ended up answering my own question with some additional research. Using a custom URL schema for android isn't necessary, and according to Google, the practice of using something like myApp:// is being deprecated.
Instead, my schema is now http://myApp.auth, and the corresponding intent filter looks like this:
<intent-filter>
<data android:scheme="http"
android:host="redfish.auth/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
Now, in Facebook's settings, I can set http://redfish.auth as an acceptable OAuth URL, and it won't complain since it has the http schema. This overrides the host rather than the schema, so it works in Chromium browsers (previously did not because of the aforementioned Chrome standards).
So, when I make a call to http://redfish.auth/facebooklogin, it redirects back to my app!
References: https://developer.android.com/guide/components/intents-filters.html
I'm trying to respond to Google Maps Uri intent for my Activity. After a quick Google search, I found this:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="https" android:host="maps.google.com" />
<data android:scheme="geo" />
</intent-filter>
source: How intercept a google maps intent in Android?
What's the equivalent of this Intent Filter in Xamarin.Android for my Activity?
Currently, I attempted this:
[IntentFilter(new[] { "android.intent.action.VIEW" }, Categories = new[] {"android.intent.category.DEFAULT", "android.intent.category.BROWSABLE"}, DataScheme = "https", DataHost = "maps.google.com" )]
But it doesn't seem to work. I'm quite confused on how to specify the additional
<data android:scheme="geo" />
Any pointers? Thanks.
It seems that there's different way to write them. For example, the following
[IntentFilter (new[]{Intent.ActionView}]
produces <action android:name="android.intent.action.VIEW" />
And for category: Link and Examples
I'm trying to save a string of user inputs to a file in a windows runtime app. However I'm getting the error System.UnauthorizedAccessException. How do I gain access to this Library?
static private async Task WriteDataToFileAsync(string fileName, string content)
{
byte[] data = Encoding.Unicode.GetBytes(content);
var folder = KnownFolders.DocumentsLibrary;
var file = await folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
using (var s = await file.OpenStreamForWriteAsync())
{
await s.WriteAsync(data, 0, data.Length);
}
}
"Documents library" capability in Visual Studio 2013 has been removed since it is only available for Windows Store Company accounts. Without this capability you will get "Access is denied".
For more information, read here: http://lunarfrog.com/blog/2013/07/05/documents-library-capability-winrt/
Like this, notice under 'Extensions' I specify the file type I want to access (.txt) and then under 'Capabilities' I have added 'documentsLibrary'.
Then to actually write or access a file from there, something like this.
var file = await KnownFolders.DocumentsLibrary.CreateFileAsync("myFile.txt", CreationCollisionOption.ReplaceExisting);
await FileIO.WriteTextAsync(file, data);
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
<Identity Name="testapp" Publisher="CN=test.test" Version="1.5.0.3" />
<Properties>
<DisplayName>test.MetroApp</DisplayName>
<PublisherDisplayName>test.test</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.0</OSMinVersion>
<OSMaxVersionTested>6.3.0</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="test.MetroApp.App">
<m2:VisualElements DisplayName="test.MetroApp" Square150x150Logo="Assets\test.png" Square30x30Logo="Assets\SmallLogo.png" Description="test.MetroApp" ForegroundText="light" BackgroundColor="#464646">
<m2:SplashScreen Image="Assets\test.scale-620.png" BackgroundColor="#464646" />
<m2:InitialRotationPreference>
<m2:Rotation Preference="landscape" />
</m2:InitialRotationPreference>
</m2:VisualElements>
<Extensions>
<Extension Category="windows.fileTypeAssociation">
<FileTypeAssociation Name="1">
<DisplayName>AccessTXT</DisplayName>
<SupportedFileTypes>
<FileType>.txt</FileType>
</SupportedFileTypes>
</FileTypeAssociation>
</Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="privateNetworkClientServer" />
<Capability Name="musicLibrary" />
<Capability Name="documentsLibrary" />
</Capabilities>
</Package>
According to the docs "your app must use the File Type Association declaration in the app manifest file to explicitly declare what file types (extensions) will be accessed or created in the Documents library".
I'm copying the MyApp.exe.config file to a separate location as an xml.
I'm using this custom config file to access and changes some settings when the application is running, rather than using the ConfigurationManager.<section> to modify the app.config.
The problem is, the default app.config file might be updated at later stage on the user machine and I want to propagate these changes back to my custom config file.
What is the best way to do this?
<configSections>
<section name="" type="" />
</configSections>
<appSettings>
<add key="" value="" />
</appSettings>
<ConnectionManangerProviders>
<provider name="" enabled="" type="">
<pollingInterval></pollingInterval>
</provider>
</ConnectionManagerProviders>
<QueueManagerProviders>
<provider name="" enabled="" type="unique" encrypted="" signed="" cryptoProvider="" />
<provider name="" enabled="" type="unique" encrypted="" signed="" cryptoProvider="">
<queueName></queueName>
</provider>
<provider name="" enabled="" type="unique" encrypted="" signed="" cryptoProvider="">
<applicationName></applicationName>
<connectionString></connectionString>
</provider>
</QueueManagerProviders>
For example, this is how the configuration file looks. Let's say one of the values of the element under <QueueManagerProviders> is modified in the app.config, how can I pass the data in this file to a method so that the method can effectively parse through it and update the appropriate section in the custom config file that I created?
This screams something about bad design, there are probably better ways to implement the whole functionality. But, if you are not in control of the "Services" part then you are stuck...
You probably need FileSystemWatcher which "Listens to the file system change notifications and raises events when a directory, or file in a directory, changes."
Add an event handler and, if your file changes, read the whole file again and parse it.
Implement a custom ConfigSection Handler (see http://msdn.microsoft.com/en-us/library/2tw134k3(v=vs.100).aspx).