<?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>Digital Memo &#187; active directory</title>
	<atom:link href="http://digitalmemo.neobie.net/category/programming/active-directory/feed/" rel="self" type="application/rss+xml" />
	<link>http://digitalmemo.neobie.net</link>
	<description>All begin with 0 &#38; 1</description>
	<lastBuildDate>Tue, 06 Jul 2010 07:58:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Checking Account Status in LDAP</title>
		<link>http://digitalmemo.neobie.net/2009/08/26/checking-account-status-in-ldap/</link>
		<comments>http://digitalmemo.neobie.net/2009/08/26/checking-account-status-in-ldap/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 08:12:24 +0000</pubDate>
		<dc:creator>neobie</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[disabled account]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[useraccountcontrol]]></category>

		<guid isPermaLink="false">http://digitalmemo.neobie.net/?p=266</guid>
		<description><![CDATA[How to check if an account is disabled in LDAP? Previously I googled and someone suggest that, the &#8216;useraccountcontrol&#8217; with 512 would be disabled, 514 would be enabled. But this is too unreliable. If there are other options for that particular account are set, for example &#8220;password never expired&#8221; and &#8220;user cannot change password&#8221;, the [...]]]></description>
			<content:encoded><![CDATA[<p>How to check if an account is disabled in LDAP?</p>
<p>Previously I googled and someone suggest that, the &#8216;useraccountcontrol&#8217; with 512 would be disabled, 514 would be enabled.</p>
<p>But this is too unreliable. If there are other options for that particular account are set, for example &#8220;password never expired&#8221; and &#8220;user cannot change password&#8221;, the status would be 66048 and 66050. Too many possbility and yet unpredictable too.</p>
<p>To solve this problem, we have to look at how Computer is formed at the earliest stage. It all begins with binary number (Yes, my blog motto). We have to convert the account status from decimal to binary number. Let&#8217;s look at the example below for 512, 514, 66048, 66050 in binary form.</p>
<p>512 &#8211; 1000000000<br />
514 &#8211; 1000000010 (disabled)</p>
<p>66048 &#8211; 10000001000000000<br />
66050 &#8211; 10000001000000010 (disabled)</p>
<p>Note the different? <strong>The 2nd bit (count from right) would be &#8220;1&#8243; for the account to be disabled</strong>. So we just need to check the 2nd bit of the binary value of account status. &#8220;0&#8243; would be an enabled account!</p>
<p>Lets come back to programming. How do we check the 2nd bit of binary number? Do we use string function provided by PHP? The answer is NO! Just look at the following code:</p>
<p><code>$ac = 512;<br />
if (($ac &amp; 2)==2) {<br />
//disabled<br />
} else { // enabled }</code></p>
<p>Why is it? We use the AND operation. For example 0010 AND 0011 = 0010. Only the bits that are set in both 0010 AND 0011 are set. In this case, it would be the 2nd bit only. By using such operation, we will be able to tell if the user account control&#8217;s 2nd bit of binary number is set or not. If it is set, return binary 10 which is equal to 2 in decimal. Else, return 0 for enabled account!</p>
<div class='wp_likes' id='wp_likes_post-266'><a class='like' href="javascript:wp_likes.like(266);" title='' ><img src="http://digitalmemo.neobie.net/wp-content/plugins/wp-likes/images/like.png" alt='' border='0'/>Like</a><span class='text'></span>
<div class='unlike'><a href="javascript:wp_likes.unlike(266);">Unlike</a></div>
</div>
<div id="crp_related"><h3>Posts which might interest you:</h3><ul><li><a href="http://digitalmemo.neobie.net/2009/02/04/on-resume-display-welcome-screen-missing/" rel="bookmark" class="crp_title">&#8220;On resume, display welcome screen&#8221; missing</a></li><li><a href="http://digitalmemo.neobie.net/2009/10/21/pre-loading-windows-programs-while-securing-your-windows-account/" rel="bookmark" class="crp_title">Pre-loading windows programs while securing your Windows Account</a></li><li><a href="http://digitalmemo.neobie.net/2009/08/08/reviews-on-malaysia-web-hostings/" rel="bookmark" class="crp_title">Reviews on Malaysia Web Hostings</a></li><li><a href="http://digitalmemo.neobie.net/2009/02/25/warning-phishing-forgery-website/" rel="bookmark" class="crp_title">Warning! Phishing / forgery website</a></li><li><a href="http://digitalmemo.neobie.net/2010/03/08/solution-vmware-mac-os-stuck-at-grey-screen-with-apple/" rel="bookmark" class="crp_title">Solution: VMWARE Mac OS stuck at grey screen with apple.</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div><img src="http://digitalmemo.neobie.net/wp-content/plugins/pixelstats/trackingpixel.php?post_id=266&amp;ts=1280435289" style="display:none;" alt="pixelstats trackingpixel"/>]]></content:encoded>
			<wfw:commentRss>http://digitalmemo.neobie.net/2009/08/26/checking-account-status-in-ldap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
