<?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>blog.nicolas.pawlak.fr &#187; ASP</title>
	<atom:link href="http://blog.nicolas.pawlak.fr/categories/programmation/asp/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nicolas.pawlak.fr</link>
	<description>Tux ne sait pas voler, c&#039;est normal : ce n&#039;est pas un pingouin...</description>
	<lastBuildDate>Sun, 31 Jul 2011 14:56:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Fonction ASP de recherche d&#8217;un utilisateur Active Directory</title>
		<link>http://blog.nicolas.pawlak.fr/2010/07/24/fonction-asp-de-recherche-dun-utilisateur-active-directory/</link>
		<comments>http://blog.nicolas.pawlak.fr/2010/07/24/fonction-asp-de-recherche-dun-utilisateur-active-directory/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 09:00:06 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[ASP]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[active]]></category>
		<category><![CDATA[ad]]></category>
		<category><![CDATA[annuaire]]></category>
		<category><![CDATA[attribut]]></category>
		<category><![CDATA[dc]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[fonction]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[ou]]></category>
		<category><![CDATA[recherche]]></category>
		<category><![CDATA[recordset]]></category>
		<category><![CDATA[subtree]]></category>
		<category><![CDATA[utilisateur]]></category>
		<guid isPermaLink="false">http://blog.nicolas.pawlak.fr/?p=1161</guid>
		<description><![CDATA[&#60;% Function RechercheUtilisateur&#40;utilisateur, attribut&#41; &#160; 'Déclaration des variables Dim objConn, objRS Dim Base, Filtre, Scope, Cmd Dim ServeurAD, CompteAD, PwdAD, OU, DC, AttributFiltre &#160; 'Paramétrage ServeurAD = &#34;127.0.0.1&#34; 'Machine hébergeant Active Directory CompteAD = &#34;DOMAINE\admin.ad&#34; 'Utilisateur autorisé à interroger Active Directory PwdAD = &#34;********&#34; 'Mot de passe de cet utilisateur OU = &#34;OU=Utilisateurs&#34; 'OU à [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="asp" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;%</span>
<span style="color: #0000ff; font-weight: bold;">Function</span> RechercheUtilisateur<span style="color: #006600; font-weight:bold;">&#40;</span>utilisateur, attribut<span style="color: #006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color: #008000;">'Déclaration des variables</span>
<span style="color: #990099; font-weight: bold;">Dim</span> objConn, objRS
<span style="color: #990099; font-weight: bold;">Dim</span> Base, Filtre, Scope, Cmd
<span style="color: #990099; font-weight: bold;">Dim</span> ServeurAD, CompteAD, PwdAD, OU, DC, AttributFiltre
&nbsp;
<span style="color: #008000;">'Paramétrage</span>
ServeurAD <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;127.0.0.1&quot;</span>           <span style="color: #008000;">'Machine hébergeant Active Directory</span>
CompteAD <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;DOMAINE\admin.ad&quot;</span>     <span style="color: #008000;">'Utilisateur autorisé à interroger Active Directory</span>
PwdAD <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;********&quot;</span>                <span style="color: #008000;">'Mot de passe de cet utilisateur</span>
OU <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;OU=Utilisateurs&quot;</span>            <span style="color: #008000;">'OU à interroger</span>
DC <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;DC=domaine,DC=fr&quot;</span>           <span style="color: #008000;">'DC à interroger</span>
AttributFiltre <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;sAMAccountName&quot;</span> <span style="color: #008000;">'Filtre de recherche de l'utilisateur</span>
&nbsp;
<span style="color: #008000;">'Connexion à l'annuaire Active Directory</span>
<span style="color: #990099; font-weight: bold;">Set</span> objConn <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #330066;">CreateObject</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;ADODB.Connection&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span>
objConn.<span style="color: #9900cc;">Provider</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;ADsDSOObject&quot;</span>
objConn.<span style="color: #330066;">Properties</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;User ID&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> CompteAD
objConn.<span style="color: #330066;">Properties</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;Password&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> PwdAD
objConn.<span style="color: #330066;">Properties</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;Encrypt Password&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">true</span>
objConn.<span style="color: #330066;">Open</span>
&nbsp;
<span style="color: #008000;">'Création de la requête</span>
<span style="color: #990099; font-weight: bold;">if</span> attribut<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;&quot;</span> <span style="color: #990099; font-weight: bold;">then</span>
        <span style="color: #008000;">'Permet la recherche simple de l'utilisateur (sans recherche d'attribut)</span>
	attribut <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;sAMAccountName&quot;</span>
<span style="color: #990099; font-weight: bold;">end</span> <span style="color: #990099; font-weight: bold;">if</span>
Base <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;&lt;LDAP://&quot;</span> <span style="color: #006600; font-weight: bold;">&amp;</span> ServeurAD <span style="color: #006600; font-weight: bold;">&amp;</span> <span style="color: #cc0000;">&quot;/&quot;</span> <span style="color: #006600; font-weight: bold;">&amp;</span> OU <span style="color: #006600; font-weight: bold;">&amp;</span> <span style="color: #cc0000;">&quot;,&quot;</span> <span style="color: #006600; font-weight: bold;">&amp;</span> DC <span style="color: #006600; font-weight: bold;">&amp;</span> <span style="color: #cc0000;">&quot;&gt;&quot;</span>
Filtre <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;(&quot;</span> <span style="color: #006600; font-weight: bold;">&amp;</span> AttributFiltre <span style="color: #006600; font-weight: bold;">&amp;</span> <span style="color: #cc0000;">&quot;=&quot;</span> <span style="color: #006600; font-weight: bold;">&amp;</span> utilisateur <span style="color: #006600; font-weight: bold;">&amp;</span> <span style="color: #cc0000;">&quot;)&quot;</span>
Scope <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;subtree&quot;</span>
Cmd <span style="color: #006600; font-weight: bold;">=</span> Base <span style="color: #006600; font-weight: bold;">&amp;</span> <span style="color: #cc0000;">&quot;;&quot;</span> <span style="color: #006600; font-weight: bold;">&amp;</span> Filtre <span style="color: #006600; font-weight: bold;">&amp;</span> <span style="color: #cc0000;">&quot;;&quot;</span> <span style="color: #006600; font-weight: bold;">&amp;</span> attribut <span style="color: #006600; font-weight: bold;">&amp;</span> <span style="color: #cc0000;">&quot;;&quot;</span> <span style="color: #006600; font-weight: bold;">&amp;</span> Scope
<span style="color: #990099; font-weight: bold;">set</span> objRS <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #990099; font-weight: bold;">Server</span>.<span style="color: #330066;">CreateObject</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;ADODB.Recordset&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span>
<span style="color: #990099; font-weight: bold;">set</span> objRS <span style="color: #006600; font-weight: bold;">=</span> objConn.<span style="color: #330066;">Execute</span><span style="color: #006600; font-weight:bold;">&#40;</span>Cmd<span style="color: #006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color: #990099; font-weight: bold;">If</span> objRS.<span style="color: #9900cc;">RecordCount</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #800000;">0</span> <span style="color: #990099; font-weight: bold;">Then</span>
        <span style="color: #008000;">'Aucun utilisateur trouvé</span>
	RechercheUtilisateur <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">false</span>
<span style="color: #990099; font-weight: bold;">Else</span>
	<span style="color: #990099; font-weight: bold;">if</span> IsNull<span style="color: #006600; font-weight:bold;">&#40;</span>objRS<span style="color: #006600; font-weight:bold;">&#40;</span>attribut<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #990099; font-weight: bold;">then</span>
		<span style="color: #008000;">'Utilisateur trouvé, attribut recherché vide</span>
		RechercheUtilisateur <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;NULL&quot;</span>
	<span style="color: #990099; font-weight: bold;">else</span>
		<span style="color: #990099; font-weight: bold;">if</span> attribut<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;sAMAccountName&quot;</span> <span style="color: #990099; font-weight: bold;">then</span>
			<span style="color: #008000;">'Utilisateur trouvé, pas d'attribut recherché</span>
			RechercheUtilisateur <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">true</span>
		<span style="color: #990099; font-weight: bold;">else</span>
			<span style="color: #008000;">'Utilisateur trouvé, attribut recherché non-nul</span>
			RechercheUtilisateur <span style="color: #006600; font-weight: bold;">=</span> objRS<span style="color: #006600; font-weight:bold;">&#40;</span>attribut<span style="color: #006600; font-weight:bold;">&#41;</span>
		<span style="color: #990099; font-weight: bold;">end</span> <span style="color: #990099; font-weight: bold;">if</span>
	<span style="color: #990099; font-weight: bold;">end</span> <span style="color: #990099; font-weight: bold;">if</span>
<span style="color: #990099; font-weight: bold;">End</span> <span style="color: #990099; font-weight: bold;">If</span>
&nbsp;
<span style="color: #008000;">'Fermeture du recordset et de la connexion</span>
objRS.<span style="color: #330066;">Close</span>
objConn.<span style="color: #330066;">Close</span>
&nbsp;
<span style="color: #990099; font-weight: bold;">End</span> <span style="color: #0000ff; font-weight: bold;">Function</span>
<span style="color: #000000; font-weight: bold;">%&gt;</span></pre></div></div>
<p>Exemple de recherche avec un attribut en paramètre :</p>
<div class="wp_syntax"><div class="code"><pre class="asp" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;%</span>
<span style="color: #990099; font-weight: bold;">Response</span>.<span style="color: #330066;">Write</span> <span style="color: #cc0000;">&quot;E-mail : &quot;</span> <span style="color: #006600; font-weight: bold;">&amp;</span> RechercheUtilisateur<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;utilisateur.alpha&quot;</span>, <span style="color: #cc0000;">&quot;mail&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">%&gt;</span></pre></div></div>
<p>Résultat :</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">E-mail : utilisateur.alpha@domaine.fr</pre></div></div>
<p>Exemple de recherche &laquo;&nbsp;simple&nbsp;&raquo; :</p>
<div class="wp_syntax"><div class="code"><pre class="asp" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;%</span>
<span style="color: #990099; font-weight: bold;">Response</span>.<span style="color: #330066;">Write</span> <span style="color: #cc0000;">&quot;Utilisateur existant : &quot;</span>
<span style="color: #990099; font-weight: bold;">if</span> RechercheUtilisateur<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;utilisateur.alpha&quot;</span>,<span style="color: #cc0000;">&quot;&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">=</span><span style="color: #0000ff; font-weight: bold;">true</span> <span style="color: #990099; font-weight: bold;">then</span>
	<span style="color: #990099; font-weight: bold;">Response</span>.<span style="color: #330066;">Write</span> <span style="color: #cc0000;">&quot;oui&quot;</span>
<span style="color: #990099; font-weight: bold;">else</span>
	<span style="color: #990099; font-weight: bold;">Response</span>.<span style="color: #330066;">Write</span> <span style="color: #cc0000;">&quot;non&quot;</span>
<span style="color: #990099; font-weight: bold;">end</span> <span style="color: #990099; font-weight: bold;">if</span>
<span style="color: #000000; font-weight: bold;">%&gt;</span></pre></div></div>
<p>Résultat :</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Utilisateur existant : oui</pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicolas.pawlak.fr/2010/07/24/fonction-asp-de-recherche-dun-utilisateur-active-directory/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Déterminer si une année est bissextile ou non</title>
		<link>http://blog.nicolas.pawlak.fr/2010/01/19/determiner-si-une-annee-est-bissextile-ou-non/</link>
		<comments>http://blog.nicolas.pawlak.fr/2010/01/19/determiner-si-une-annee-est-bissextile-ou-non/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 13:00:22 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[ASP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[année]]></category>
		<category><![CDATA[bissextile]]></category>
		<category><![CDATA[calendrier]]></category>
		<category><![CDATA[divisible]]></category>
		<category><![CDATA[grégorien]]></category>
		<category><![CDATA[julien]]></category>
		<category><![CDATA[modulo]]></category>
		<guid isPermaLink="false">http://blog.nicolas.pawlak.fr/?p=465</guid>
		<description><![CDATA[&#171;&#160;Une année bissextile est une année divisible par 4. Une année est bissextile une fois sur 4.&#160;&#187; Ces deux affirmations sont bien ancrées dans la croyance populaire. Moi aussi, il y a peu, j&#8217;y croyais. Pourtant&#8230; tout ceci est totalement faux. Le calendrier grégorien, en vigueur en France depuis 1532, indique qu&#8217;une année bissextile doit [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p></p>
<p align="center">&laquo;&nbsp;Une année bissextile est une année divisible par 4. Une année est bissextile une fois sur 4.&nbsp;&raquo;</p>
</blockquote>
<p>Ces deux affirmations sont bien ancrées dans la croyance populaire. Moi aussi, il y a peu, j&#8217;y croyais.</p>
<p>Pourtant&#8230; tout ceci est totalement <strong>faux</strong>. Le <a href="http://fr.wikipedia.org/wiki/Calendrier_gr%C3%A9gorien">calendrier grégorien</a>, en vigueur en France depuis 1532, indique qu&#8217;une année bissextile doit répondre à l&#8217;une de ces deux règles :</p>
<p>• Divisible par 400<br />
• Divisible par 4 et non divisible par 100</p>
<p>Si vous faites le calcul, vous vous apercevrez que <em>quasiment</em> chaque année bissextile obéit à l&#8217;une de ces deux règles. Oui, <em>quasiment</em> : il y a effectivement des années divisibles par 4 qui n&#8217;obéissent à aucune de ces deux règles. Essayez avec 2100 par exemple : cette année est non divisible par 400, divisible par 4&#8230; mais divisible par 100. Il s&#8217;agit bel et bien d&#8217;une année non bissextile, alors que 2096 et 2104 seront des années bissextiles.</p>
<p>Évidemment, ça ne concerne que peu d&#8217;années : il y a en fait 97 années bissextiles en 4 siècles alors que la croyance populaire en compte 100. Mais dans certains domaines comme la généalogie, déterminer avec exactitude si une année est bissextile ou non peut avoir son importance.</p>
<p>Voici donc deux bouts de code en ASP et en PHP vous permettant de déterminer à coup sûr si une année est bissextile.</p>
<p><strong>ASP :</strong></p>
<div class="wp_syntax"><div class="code"><pre class="asp" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">function</span> EstBissextile<span style="color: #006600; font-weight:bold;">&#40;</span>annee<span style="color: #006600; font-weight:bold;">&#41;</span>
    <span style="color: #990099; font-weight: bold;">if</span> annee mod <span style="color: #800000;">4</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #800000;">0</span> <span style="color: #0000ff; font-weight: bold;">and</span> annee mod <span style="color: #800000;">100</span> <span style="color: #006600; font-weight: bold;">&lt;&gt;</span> <span style="color: #800000;">0</span> <span style="color: #0000ff; font-weight: bold;">or</span> annee mod <span style="color: #800000;">400</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #800000;">0</span> <span style="color: #990099; font-weight: bold;">then</span>
        EstBissextile <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">true</span>
    <span style="color: #990099; font-weight: bold;">else</span>
        EstBissextile <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">false</span>
    <span style="color: #990099; font-weight: bold;">end</span> <span style="color: #990099; font-weight: bold;">if</span>
<span style="color: #990099; font-weight: bold;">end</span> <span style="color: #0000ff; font-weight: bold;">function</span></pre></div></div>
<p><strong>PHP :</strong></p>
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> EstBissextile<span style="color: #009900;">&#40;</span><span style="color: #000088;">$annee</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$annee</span><span style="color: #339933;">%</span><span style="color:#800080;">4</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> and <span style="color: #000088;">$annee</span><span style="color: #339933;">%</span><span style="color:#800080;">100</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span> or <span style="color: #000088;">$annee</span><span style="color: #339933;">%</span><span style="color:#800080;">400</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$bissextile</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$bissextile</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$bissextile</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>
<p>Pour plus d&#8217;informations sur les années bissextiles, je vous recommande vivement la lecture de <a href="http://fr.wikipedia.org/wiki/Ann%C3%A9e_Bissextile">l&#8217;article Wikipédia à ce sujet</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicolas.pawlak.fr/2010/01/19/determiner-si-une-annee-est-bissextile-ou-non/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

