Find out the launch points of active IE instances of windows - c#

We have an application that runs as service on windows. The service periodically checks for active Internet Explorer instances using SHDocVw.ShellWindows(). With this, we are able to capture the URL in each of the IE instances.
My Question:
Is it possible to find out how the webpage in each of these IE instances were launched. For example -
Did user type in url in IE to load the webpage?
Did the user select the link from another IE tab to launch ?
Did the user launch IE instance from another desktop application like outlook etc
Thank you.

The closest thing I could find to your specific requirement was this also check out the part 2 of the same blog where some edge cases have been discussed.
The part 1 of the blog talks about a registry key named TypedURLs (path: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TypedURLs) which can be found in the registry editor, the rules of updation of this key are like this:
If a link is copied and pasted from a web page to the URL address bar and the user hits enter, this will also populate the key, as this is akin to physically typing in the entire address. If an invalid address of a webpage or resource that cannot be located is entered, the key will not be populated until either the connection or the request is completed (whether it succeeded or failed). If IE’s Stop function is selected before the connection is finished or the resource is located, the key will not be populated.
It is important to note that websites visited with the browser via hyperlinks, redirects, the IE Favorites menu or the user’s home page will not populate this key. Also, when a user selects to delete their browsing history using IE’s built-in function, this key is cleared.
Hope it helps!

Related

C# - Get Url from browser

So just like uTorrent gets magnet links and opens them,
How can I setup my WinForm app to get a URL from Default Browser (in this case my default is Chrome) and open that URL in EO.WebBrowser within my app?
I don't have any code for this yet, as I don't know where to start.
Is this something that would be assigned as a Registry Key?
I know there are Registry keys for uTorrent to handle Magnet links in HKEY_CLASSES_ROOT\Magnet\shell\open\command.
What I have is WhatsApp Web open in EO.WebBrowser, and when I click on a URL starting with https://web.whatsapp.com or https://api.whatsapp.com it would open that link. The thing is the link should be changed to web.whatsapp.com, instead of api.whatsapp.com

How to restrict a website to get access to a specific path through IIS?

I'm looking for a way to restrict a website served by IIS so that the website can get access to the specific folder or drive not more, let me illustrate it.
Imagine I have two websites A and B served by IIS, you can put following code in code-behind of both websites:
string windowsPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows)
string path = windowsPath + #"\Microsoft.NET\Framework";
var directories = Directory.GetDirectories(path);
I need a way through IIS to restrict website A not be able to get access to the mentioned directories and only website B be able to do that. In other words I want to restrict read access.
I suppose it should have a simple solution because it's what hosting servers deal with. It's obvious that you can't put a piece of code in your website in a web hosting server and simply get access to list files name located in drive C of the hosting server.
How can I achieve that?
After researching a lot I found the solution, I thought it might be useful for ones who will stumble upon this matter later, so I documented the solution.
Note:
From IIS 7.5 on, you have more access on user who is running a website.
Every application pool you make, creates an internal user which is hidden and is known as AppPoolIdentity.
The goal:
Imagine We have two websites A and B, we also have a folder named SecurityTest located in D:\Temp, there are 6 folders inside it under the names 1 to 6, we consider to allow website A get the name of the folders inside SecurityTest while we tend to prevent website B to do that.
Step 1:
Firstly, create a website through VisualStudio, I put a server side button in the form, I consider to get name of folders in the specified path (say D:\Temp\SecurityTest), So here's the code I place in code behind to be triggered when the button is clicked:
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = string.Empty;
string path = #"D:\Temp\SecurityTest";
var directories = Directory.GetDirectories(path);
for (int i = 0; i < directories.Length; i++)
{
string fileName = Path.GetFileName(directories[i]);
Label1.Text += fileName + "<br />";
}
}
Step 2: Now let's deal with IIS. Add two websites (or applications) to the IIS, name them A and B, the physical path for both are the same, only change port number, for instance set 81 as port number for website A and 82 for website B. Note that new application pool is created by default with the same name of your website (if you create a new application instead of new website, you should create a new application pool by yourself).
Step 3: Now in the Connections pane, click on website A, from middle pane, double click on Authentication located in the IIS category. Then click on Anonymous Authentication, after that from 'Actions' pane at the right side, click on Edit.
Now select Application pool identity and click on OK. By following these steps you chose AplicationPoolIdentity user as the user who handles website A. Follow these steps for website B.
Step 4: Go to the pathD:\Temp, right click on the folder named SecurityTest, on the Security tab, on the Group or user names category, you can see users listed who have access to the folder, these users are granted permission at the creation time by default. You might see more or less though but the point is that you should add website A ApplicationPoolIdentity user and remove all other users, so remove Users which gives access to all users, after that remove Authenticated users from the list too.
Keep in mind that you can't simply remove these users, you should Disable Inheritance first. here's the steps to achieve that:
Since you tend to allow website A to get directories, you need to add the user corresponding to the website A, now you need to follow the next step.
Step 4-1: On the same dialogue, click on Add to add new user, from here you can't find the user related to the website A since it's a hidden and internal (and virtual) user, I mean the AppPoolIdentity user for website A. You should type the name on the following pattern:
IIS APPPOOL\<app_pool_name>
So for website A I should type IIS APPPOOL\A, click on Check Names to make sure whether the user exists or not, finally press OK button.
Step 4-2: To prevent other users to get access to the webite A, click on Advanced button, click on Disable inheritance, when you encounter the warning message, select the first option (Convert) preferably, then press OK to close the dialogue.
Now in Security tab, click on Edit button to change permissions. Here you can remove users you don't need, like Authenticated Users and Users. From now on both websites A and B won't be able to get folders name.
Now get back to IIS panel and click on website A in the left Pane, then click on Browse *:81 (http) link, you can see the website A on your browser, do the same for website B to open it in the browser. When you click on button in website A you can observe a list of folders from 1 t 6 while you get following error when you click on the button to get directories on the website B.
Access to the path 'D:\Temp\SecurityTest' is denied.
That's all you need to do.
If you understand how pipeline work, you would know that we can only filter permission based by injecting module. So there are few things we can do with IIS configuration.
Asp.net application activated under IIS worker process with Application pool identity. Since Site A and Site B used different managed service account. You could remove IIS apppool\A's permission to prevent site A from reading folder.
Since read permission for application pool identity to access windows\microsoft.net is necessary when activating worker process. It is not recommended to restrict the permission

Launch Outlook from web application and open specific calendar entry

I have a requirement to display a user's calendar entries for the next month on a web application dashboard view.
I have successfully used Exchange Web Services to achieve this following this documentation:
https://msdn.microsoft.com/en-us/library/office/dn495614(v=exchg.150).aspx
The final requirements for this task are that if the user clicks on the entry (in their browser):
Outlook should open on their machine and take them straight to the actual calendar entry.
I've inspected the appointment objects and I can see I have access to the calendar Id and I can easily pass this to the server however from here I'm a little confused how I can launch the application that is on their machine and tell it to open that entry Id.
Would this be another EWS call or Office.Interop.Outlook, is it even possible at all?
If this makes it anymore difficult, this is a .Net Core 2.0 web application.
Outlook still accepts command line switches, one of which let's you open an Outlook item, /select.
Now you just need to create a URL to launch Outlook with your command line arguments.
For IE, this is not too difficult assuming your web application is trusted:
javascript:(new ActiveXObject('Shell.Application')).ShellExecute('outlook.exe','/select outlook:<entryid>');
For Chrome, you could send a cmd file or create a helper exe that is downloaded, but the user would have to manually pick open to launch it.
Active X will not be working for all the modern browsers like chrome, IEEdge, firefox and safari. Alternatively you can create below registry entry and anchor link/button to open the outlook calendar
below is the markup
<button id="outlookCalendarBtn" onclick="window.open('outlookwebcal:')">
Open Outlook Calendar
</button>
Create below registry entry
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\outlookwebcal]
#="URL:Outlook Add Internet Calendar"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\outlookwebcal\shell]
#="open"
[HKEY_CLASSES_ROOT\outlookwebcal\shell\open]
[HKEY_CLASSES_ROOT\outlookwebcal\shell\open\command]
#="\"C:\\Program Files\\Microsoft Office\\root\\office16\\Outlook.exe\" /select outlook:calendar"

Caching of "multiple sites" with Windows Phone 8.1

I have this weird problem my website won't cache the mainsite!
Here is a little overview about what I am trying to do
The first page that is being loaded is the
[DidTheUserLoggedInBefore?.html]
which checks if the user already has logged in or not depending on that result the user will be redirected to
either [LOGIN.html] or [MAINPAGE.HTML]
pretty simple!
But here comes the problem when the user restarts the app in Offline mode the App should redirect immediately to the mainpage (assuming the previous login was a success).
But that doesnt happen at all.
Instead the [DidTheUserLoggedInBefore?.html] from cache was called (which is correct) and starts loading the mainpage which isnt in cache which results in a whitescreen aka my error.
So how do I get my App to cache the Mainpage?
I've tried setting CacheSize to 100, but that didn't changed a thing :(
You can't check if the user has logged in with a .html file... You need some sort of server side language to set a cookie... Anyway this isn't much clear, is your "app" just a webview?
I couldn't let the webview cache more than 2 (simple) webpages...
WebView ignores he offline.manifest.php file too ...

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

Categories

Resources