Adding a 'User' to the eventlog using Enterprise Library Logging Block - c#

I'm using the Enterprise Library Logging application block to allow my application to log various events. This is working fine and the logs can be seen by Event Viewer (eventvwr.exe) going into the Application log.
However, Event Viewer always shows the user field as "N/A". Other applications have the field populated - how do I populate this field?
I have the current user logged into the extended properties of the log entry (using the UnmanagedSecurityContextInformationProvider). This means that I can capture the username and have it appear within Event Viewers 'Description' text box - but I cannot use EventViewer's filtering to see one user's log entries.

I've since found this question which suggests this is not possible without breaking into unmanaged Win32 API code - and a posting over on another site that has a MSFT employee stating the same.
Looks like I'll have to just put the username in the main body of the message.

Related

Facebook SDK - Handling application invites?

With the Facebook SDK it seems like they allow you to invite your friends to join the application through the AppRequest section of the SDK. However I don't see anywhere in the SDK where you can reward users for inviting friends. I know this is possible because it's been done so many times, so how it can be done?
For example, lets say:
1. User A invites User B to use the application.
2. User B downloads the application.
3. User A receives 100 coins for inviting User B.
I'm completely lost here, examples using any SDK, regardless of language, would be appreciated.
Since Facebook app invites are based on AppLinks, that is where you need to look for a solution. I will explain this by using an Android example scenario.
When constructing an app invite (using the dialog), you are specifying an AppLinks URL. This URL can be unique to each user that sends out invites, or even to each individual invite. E.g.: https://www.example.com/invite_applink?invite_id=12345. By creating one AppLink url for e.g. each user who invites others, you embed invite-sender attribution (which is what you are saying you want) into your AppLinks URL.
The way the Facebook app figures out how to open your app from the "app invites" section, is by following the AppLinks specification.
This specification states that in the <head> section of the HTML document that lives at https://www.example.com/invite_applink, there has to be appropriate <meta> data that describes how your app can be opened/deep-linked into. One part of that is the al:android:url property, which could be used like this: <meta property="al:android:url" content="example://invite_from_fb?invite_id=12345" />
Observe how the url contains a parameter invite_id=12345, where 12345 is the same value as the one used in the invite_id parameter of the AppLinks URL above.
When the invited user now opens the app from the deep-linking URI example://invite_from_fb?invite_id=12345, the app will be opened from an intent that contains this information.
When your app's Activity opens you can grab the Intent that opened the Activity, and get from it the Uri that was used to open the app: Intent.getData(). More on this on the Android docs on "Allowing other Apps to Start Your Activity"
At this point, the ID that attributes an app invite to a user has made from the sender into the running app of the recipient. Now the app on the recipient's device needs to call your server and let it know which invite_id was used to open it. To avoid that multiple such attributions originate from one user (who may have received invites from multiple people), you could hold off on sending this attribution data until the user has performed some sort of login (e.g. Facebook Login) and you are able to ignore e.g. all attributions after the first one.

How to send a mail to user by using Sitecore Rules

I am trying to send a mail to user by using Sitecore rules.
I created a rule in Item Saved event in Rules.
My Rule is like this
"where user profile Fullname field is not empty
send Newsletter Message 10T023615 e-mail"
but it doesn't make any sense.Please can anyone explain me how the rule works and when the Item saved event fire.
A Rule consists of 2 parts: a Condition and an Action.
The Condition part of your Rule you mention there is:
where user profile Fullname field is not empty
The Action part of your Rule is:
send Newsletter Message 10T023615 e-mail
When the rule runs and the Condition evaluates to True it will trigger the action. You'll need to have that rule trigger on some type of action of a visitor.
You can add rules for instance to specific components, to do personalization for example.
Just looking at your rule it would seem to me that for this type of thing you'd create an Engagement Plan. For more information on Engagement Plans, please take a look at this article on doc.sitecore.net. This is a walkthrough for editing message engagement plans. This is written for Sitecore 8, if you're interested in an older version I know there's cookbooks available for engagement automation on Sitecore's Develop Network.

Google Admin Directory API SDK User Last Logged In Not Fully Accurate

I use the .Net API for managing my organization's users within Google Apps. Within the directory API you can "RetrieveUser". This returns a User object that has a date property of "LastLoginTime".
Google used to separate out their Last Login Time for an account into three categories using the previous api.
last_login_time - the last time you directly logged into a google service using a UI
last_web_mail_time - the last time you logged into gmail.com webmail
last_pop_time - the last time you popped or imap'ed from their server. (indirect login)
In the new SDK, I don't see a specific "How we populate this" comment within their documentation. I'm wondering, and having trouble testing to figure out the rules myself:
How this is populated?
If it is not all encompassing usage that updates this date (usage meaning ANY interaction between the user and their account), how do I get other dates?
I use the last usage date to recycle idle users. Thus I need an accurate representation of what this date is. I've tested, and it appears popping from a google account is not represented within the SDK LastLoggedIn property, even though you need to log in to pop. Thus, any user that pops from the account and doesn't "Log In" could be deleted by accident.
API Reference
Appreciate any help.
These three (And more) properties still exist, just not attached to the "LastLoginTime". If you want to know if an account is truly idle, you'll need to use the Google.Apis.Admin.Reports.reports_v1 API. You can install via NuGet.
After you make your service object (Many stack answers can show you how to do this), usage is below:
UserUsageReportResource resource = _service.UserUsageReport;
UserUsageReportResource.GetRequest request = resource.Get("User#domain.ca", "yyyy-mm-dd");
UsageReports report = request.Execute();
All the interaction dates will need to be searched through, including LastLoginTime, and then take the latest. Each application has different dates all pertaining to when the last time the user did X action.
LastLoginTime appears to be simply the last time a user directly, or indirectly (via device), logged into the Gmail service. This does not include logging in for pop etc.

When are the parameters used in WebResource.axd reset?

When using WebResource.axd you will see two parameters being passed in the query string. Usually looks something like this:
WebResource.axd?d=9H3mkymBtDwEocEoKm-S4A2&t=634093400273197793
I have run into an issue where I need a permanent link to the resource in question. Recently the link I was using stopped working. What would cause these ids to change? Rebooting the server? Recompiling the code? Is there anyway to make these ids permanent?
Background -
As part of a site monitoring service we are subscribed to, we have "recorded" several sets of user actions for our website. For example, we recorded the process of logging into the site. The monitoring is now saying that the user login process fails (it's working fine) because it cannot find the WebResource.axd with the ids it recorded.
This page provides all the information on the makeup of the URL
http://support.microsoft.com/kb/910442
The "d" stands for the requested Web Resource
Something worth noting is that you don't need to have the timestamp (t) parameter there to call the resource. Try it on your own site, view the source and grab a webresource.axd url and navigate to the it, remove the t

Facebook Social Graph API: "Annoying or Abusive" Error Message

I got the following exception from the Social Graph API:
(OAuthException) Block! You are engaging in behavior that may be
considered annoying or abusive by other users.: You have been blocked
from Body of an error/warning message. Title is: Block! You are
engaging in behavior that may be considered annoying or abusive by
other users. because you repeatedly misused this feature. This block
will last anywhere from a few hours to a few days. When you are
allowed to reuse this feature, please proceed with caution. Further
misuse may result in your account being permanently disabled. For
further information, please visit our {= FAQ page}.
My program makes thousands of calls, but the call that threw the exception was like this:
graph.facebook.com/search?q=6511+club&access_token=...
I'm not writing anything back to the API, so I don't see how I could be violating any abuse/annoyance rules. At first I thought I might have gone over the rate limit but this thread says the exception message for that would look like this:
Facebook.GraphAPIError: (#613) Calls to stream have exceeded the rate of 600 calls per 600 seconds.
My program is calling the above Event search endpoint with a new value for the q parameter repeatedly. For each event returned, my program:
(calls /eventId) Gets the Event detail
(calls /pageId) Get place Page of the Event's location if the Event's location references a Facebook place Page
(calls /eventId/attending) Get the ids of the User profiles who are attending or maybe attending
(calls /?ids=...) Get the User profiles of the Users who are attending or maybe attending.
I'm using the Facebook C# SDK. All my calls include an access token (from my personal User profile).
It's not your app which is blocked, it's your user which is blocked. Your user was identified by Facebook's automated system as a bot (which it really is actually). Next step - your user will be banned from Facebook. You're making too many calls harvesting data from Facebook by a single user. You need to rethink your app purpose and whther you need to call this data to store or your users can get it on demand from the API. Most offensive calls here are /eventId/attending and ids per each event. Call it thousand times on thousand events and the user will be blocked.

Categories

Resources