<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ChillAxen.com</title>
	<atom:link href="http://www.chillaxen.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chillaxen.com</link>
	<description>Everything about anything!</description>
	<lastBuildDate>Sun, 06 Feb 2011 20:47:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>ASP.net &#8211; Force a user offline as admin (destroy a session by username)</title>
		<link>http://www.chillaxen.com/2011/02/asp-net-force-a-user-offline-as-admin-destroy-a-session-by-username/</link>
		<comments>http://www.chillaxen.com/2011/02/asp-net-force-a-user-offline-as-admin-destroy-a-session-by-username/#comments</comments>
		<pubDate>Sun, 06 Feb 2011 20:46:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[membership]]></category>
		<category><![CDATA[sessions]]></category>

		<guid isPermaLink="false">http://www.chillaxen.com/?p=32</guid>
		<description><![CDATA[So today I came across an issue.  I created a membership system as I always do, which included allowing the admin to delete specific users.  Worked perfectly, but problem was, if a user is already logged in, it did not kill their session.  So basically this user is able to stay online even if they [...]]]></description>
			<content:encoded><![CDATA[<p>So today I came across an issue.  I created a membership system as I always do, which included allowing the admin to delete specific users.  Worked perfectly, but problem was, if a user is already logged in, it did not kill their session.  So basically this user is able to stay online even if they were deleted.</p>
<p>After asking people on Stack Overflow and bouncing around some ideas I decided on the following solution</p>
<ol>
<li>In my global.aspx &#8220;Application_Start&#8221; I created a new variable to hold a list of strings, so I added:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;">application<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;deleted_users&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> List<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Of</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span></pre></td></tr></table></div>

</li>
<li>Next, when I deleted a user, I injected them into the application&#8217;s list of deleted users my calling:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;">System.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">HttpContext</span>.<span style="color: #0000FF;">Current</span>.<span style="color: #0000FF;">Application</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;deleted_users&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">add</span><span style="color: #000000;">&#40;</span>username<span style="color: #000000;">&#41;</span></pre></td></tr></table></div>

</li>
<li>Finally, I needed to make sure when a user makes a request, we checked against this list of users who were deleted.  If they are in the list, kill their session.  To do this I added the following to my Global.asax:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Sub</span> MvcApplication_PreSendRequestHeaders<span style="color: #000000;">&#40;</span>sender <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Object</span>, e <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">EventArgs</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Handles</span> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">PreSendRequestHeaders</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">'This will make sure if we are logged on, we dont need to get logged off</span>
  <span style="color: #0600FF;">If</span> User.<span style="color: #0000FF;">Identity</span>.<span style="color: #0000FF;">IsAuthenticated</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span> <span style="color: #FF8000;">Then</span> <span style="color: #0600FF;">Exit</span> <span style="color: #0600FF;">Sub</span>
  <span style="color: #0600FF;">If</span> Application<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;deleted_users&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">contains</span><span style="color: #000000;">&#40;</span>User.<span style="color: #0000FF;">Identity</span>.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
    PrivateObjects.<span style="color: #0000FF;">Classes</span>.<span style="color: #0000FF;">Memberships</span>.<span style="color: #0000FF;">Logout</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></td></tr></table></div>

</li>
</ol>
<p>Something to note is by using the PreSendRequestHeaders, it processes after the page is already being sent, so the user will be allowed one more page view before his session is destroyed.  I am sure there is a different method you can use in your Global.asax that will do this at the first post, but that was enough for me!</p>
<p>Hope this helps anyone else who was having this issue</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chillaxen.com/2011/02/asp-net-force-a-user-offline-as-admin-destroy-a-session-by-username/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Searching POP3 accounts for bounced emails with vb.net</title>
		<link>http://www.chillaxen.com/2011/02/searching-pop3-accounts-for-bounced-emails-with-vb-net/</link>
		<comments>http://www.chillaxen.com/2011/02/searching-pop3-accounts-for-bounced-emails-with-vb-net/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 17:04:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[VB.net]]></category>
		<category><![CDATA[bounced emails]]></category>
		<category><![CDATA[Mailsystem.NET]]></category>
		<category><![CDATA[POP3]]></category>

		<guid isPermaLink="false">http://chillaxen.com/?p=1</guid>
		<description><![CDATA[In this article I am going to demonstrate how to develop an application in VB.net that allows you to search a list of POP3 email addresses and return all of the bounced email addresses from that email.  For ease of learning, we will create a simple single threaded console app.  This should work for most [...]]]></description>
			<content:encoded><![CDATA[<p>In this article I am going to demonstrate how to develop an application in VB.net that allows you to search a list of POP3 email addresses and return all of the bounced email addresses from that email.  For ease of learning, we will create a simple single threaded console app.  This should work for most people, but to expand on this article, try adding asynchronization and multiple threads.</p>
<div class="box toc">
<p><strong>Table Of Contents:</strong></p>
<ol>
<li><a href="/2011/02/searching-pop3-accounts-for-bounced-emails-with-vb-net/#1">Create A New Project</a></li>
<li><a href="/2011/02/searching-pop3-accounts-for-bounced-emails-with-vb-net/#2">Project Clean Up / Method Setup</a></li>
<li><a href="/2011/02/searching-pop3-accounts-for-bounced-emails-with-vb-net/2/#3">Code our method to load our POP3 file</a></li>
<li><a href="/2011/02/searching-pop3-accounts-for-bounced-emails-with-vb-net/3/#4">Code our method to process a single account</a></li>
<li><a href="/2011/02/searching-pop3-accounts-for-bounced-emails-with-vb-net/4/#5">Put it all together in our main method</a></li>
<li><a href="/2011/02/searching-pop3-accounts-for-bounced-emails-with-vb-net/4/#6">Summary / Source Code</a></li>
</ol>
</div>
<p><span id="more-1"></span>Before we begin we will assume you already have either Visual Studio 2010 or VB.net Express 2010 installed.  Please note we will be using Visual Studio 2010 professional edition in this. We will also be using a 3rd party class which will handle all of our POP3 protocol coding.  In order to download the latest copy of this class, head on over to their CodePlex project website <a href="http://mailsystem.codeplex.com/">Mailsystem.NET</a>.  Just unzip the files to a location you can easily fine and will not delete (I have a folder d:\COM Objects that I put all new class objects in) and load up visual studios.<br />
<a name="1"></a></p>
<h3><strong>1. Create A New Project</strong></h3>
<p>To start, we will create a new console project<a href="http://chillaxen.com/wp-content/uploads/2011/02/bounced-email-dumper-new-project.png"><img class="alignright size-medium wp-image-5" style="margin-left: 2px; margin-right: 2px;" title="bounced email dumper - new project" src="http://chillaxen.com/wp-content/uploads/2011/02/bounced-email-dumper-new-project-300x206.png" alt="" width="300" height="206" /></a></p>
<ul>
<li>Click File -&gt; New -&gt; Project</li>
<li>Select Visual Basics from the left treeview menu and click on Console Application</li>
<li>For name, lets name it &#8220;&#8221;.</li>
<li>Also name the Solution &#8220;Bounced Email Dumper&#8221;</li>
<li>Make sure &#8220;Create directory for solution&#8221; is selected and press &#8220;OK&#8221;</li>
</ul>
<p>You  now have the base project created!<br />
<a name="2"></a></p>
<h3>2. Project Clean Up / Method Setup</h3>
<p>Now that you have the project created, lets clean the project up a bit and create the core coding for this project.</p>
<ol>
<li>Right click on &#8220;Module1.vb&#8221; in the Solution Explorer, and lets rename it to &#8220;main.vb&#8221;.  Double click on the file to open it up and source view and make sure it is now called &#8220;Module Main&#8221; instead of &#8220;Model Module1&#8243;.  If it is not, rename it.</li>
<li>Double click on &#8220;My Project&#8221;  and go to the &#8220;Application&#8221; tab.  Make sure for startup object you have &#8220;Sub Main&#8221; selected.</li>
<li>We must now add our references.  Still in the application settings, click on the &#8220;References&#8221; tab and click &#8220;Add&#8221;.  Once the &#8220;Add Reference&#8221; dialog pops up, select the &#8220;Browse&#8221; tab.  At this point, go to the folder you extracted the MailSystem.NET class to and include &#8220;ActiveUp.Net.Pop3.dll&#8221;.  You will also want to include &#8220;ActiveUp.Net.Common.dll&#8221;</li>
</ol>
<p>Now that we have our project setup as we needed, lets go ahead and add our core methods, variables and includes.  For this we will need to create a structure that can hold all of the information for a single account, a list to hold all of our accounts left to process, a method to load our POP3 accounts for a specific folder, a method to process a specific POP3 account, and a StreamWriter to write our bounced emails to.  So at this point we have our class as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;">Module Main
&nbsp;
  <span style="color: #008080; font-style: italic;">''' &lt;summary&gt;</span>
  <span style="color: #008080; font-style: italic;">''' This will hold all of our accounts</span>
  <span style="color: #008080; font-style: italic;">''' &lt;/summary&gt;</span>
  <span style="color: #008080; font-style: italic;">''' &lt;remarks&gt;&lt;/remarks&gt;</span>
  <span style="color: #FF8000;">Private</span> accounts <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> List<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Of</span> Account<span style="color: #000000;">&#41;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">''' &lt;summary&gt;</span>
  <span style="color: #008080; font-style: italic;">''' This will hold our writer that we send the bounces to</span>
  <span style="color: #008080; font-style: italic;">''' &lt;/summary&gt;</span>
  <span style="color: #008080; font-style: italic;">''' &lt;remarks&gt;&lt;/remarks&gt;</span>
  <span style="color: #FF8000;">Private</span> writer <span style="color: #FF8000;">As</span> IO.<span style="color: #0000FF;">StreamWriter</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">''' &lt;summary&gt;</span>
  <span style="color: #008080; font-style: italic;">''' Holds how many bounce requests we found</span>
  <span style="color: #008080; font-style: italic;">''' &lt;/summary&gt;</span>
  <span style="color: #008080; font-style: italic;">''' &lt;remarks&gt;&lt;/remarks&gt;</span>
  <span style="color: #FF8000;">Private</span> bounceCount <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">''' &lt;summary&gt;</span>
  <span style="color: #008080; font-style: italic;">''' This will be all of our accounts that we need to go through</span>
  <span style="color: #008080; font-style: italic;">''' &lt;/summary&gt;</span>
  <span style="color: #008080; font-style: italic;">''' &lt;remarks&gt;&lt;/remarks&gt;</span>
  <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Structure</span> Account
    <span style="color: #FF8000;">Public</span> username <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
    <span style="color: #FF8000;">Public</span> password <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
    <span style="color: #FF8000;">Public</span> server <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
    <span style="color: #FF8000;">Public</span> port <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Long</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Structure</span>
&nbsp;
  <span style="color: #0600FF;">Sub</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">''' &lt;summary&gt;</span>
  <span style="color: #008080; font-style: italic;">''' This will load all of our pop3's into an array of username:password</span>
  <span style="color: #008080; font-style: italic;">''' &lt;/summary&gt;</span>
  <span style="color: #008080; font-style: italic;">''' &lt;returns&gt;&lt;/returns&gt;</span>
  <span style="color: #008080; font-style: italic;">''' &lt;remarks&gt;&lt;/remarks&gt;</span>
  <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Function</span> Load_POP3<span style="color: #000000;">&#40;</span><span style="color: #008000;">file</span> <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span>
    <span style="color: #FF8000;">Return</span> <span style="color: #0600FF;">False</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">''' &lt;summary&gt;</span>
  <span style="color: #008080; font-style: italic;">''' This will get all the bounce requests for a specific account</span>
  <span style="color: #008080; font-style: italic;">''' &lt;/summary&gt;</span>
  <span style="color: #008080; font-style: italic;">''' &lt;param name=&quot;acc&quot;&gt;&lt;/param&gt;</span>
  <span style="color: #008080; font-style: italic;">''' &lt;param name=&quot;minimum_level&quot;&gt;The min level we will look for when deciding if it's a bounced email&lt;/param&gt;</span>
  <span style="color: #008080; font-style: italic;">''' &lt;param name=&quot;err&quot;&gt;if there is an error, it will be held here&lt;/param&gt;</span>
  <span style="color: #008080; font-style: italic;">''' &lt;returns&gt;&lt;/returns&gt;</span>
  <span style="color: #008080; font-style: italic;">''' &lt;remarks&gt;&lt;/remarks&gt;</span>
  <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Function</span> Process_Account<span style="color: #000000;">&#40;</span>acc <span style="color: #FF8000;">As</span> Account, <span style="color: #FF8000;">ByVal</span> minimum_level <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span>, <span style="color: #FF8000;">ByRef</span> <span style="color: #008000;">err</span> <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Boolean</span>
    <span style="color: #FF8000;">Return</span> <span style="color: #0600FF;">False</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
<span style="color: #0600FF;">End</span> Module</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.chillaxen.com/2011/02/searching-pop3-accounts-for-bounced-emails-with-vb-net/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

