<?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>Indented! &#187; NameTranslate</title>
	<atom:link href="http://www.indented.co.uk/index.php/tag/nametranslate/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.indented.co.uk</link>
	<description></description>
	<lastBuildDate>Fri, 02 Jul 2010 10:45:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>VbScript: GetObjectDN</title>
		<link>http://www.indented.co.uk/index.php/2008/10/06/getobjectdn/</link>
		<comments>http://www.indented.co.uk/index.php/2008/10/06/getobjectdn/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 18:57:44 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[VbScript]]></category>
		<category><![CDATA[NameTranslate]]></category>
		<category><![CDATA[vbs]]></category>

		<guid isPermaLink="false">http://www.highorbit.co.uk/?p=121</guid>
		<description><![CDATA[Converts an NT user name into a Distinguished Name (object path) in Active Directory using the NameTranslate interface. Function GetObjectDN(strObject, strDomain) ' Return Type: String ' ' Returns a Distinguished Name for an Object from it's NT SAM ID. ' This will only function for valid object types within an NT Domain structure. Const ADS_NAME_INITTYPE_GC [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Converts an NT user name into a Distinguished Name (object path) in Active Directory using the <a href="http://msdn.microsoft.com/en-us/library/aa706046(VS.85).aspx">NameTranslate</a> interface.<br />
<span id="more-121"></span></p>
<pre class="brush: vb;">
Function GetObjectDN(strObject, strDomain)
  ' Return Type: String
  '
  ' Returns a Distinguished Name for an Object from it's NT SAM ID.
  ' This will only function for valid object types within an NT Domain structure.

  Const ADS_NAME_INITTYPE_GC = 3
  Const ADS_NAME_TYPE_1779 = 1
  Const ADS_NAME_TYPE_NT4 = 3

  If strDomain = &quot;&quot; Then
    Dim objNetwork : Set objNetwork = CreateObject(&quot;WScript.Network&quot;)
    strDomain = objNetwork.UserDomain
    Set objNetwork = Nothing
  End If

  On Error Resume Next : Err.Clear
  Dim objNameTranslate : Set objNameTranslate = CreateObject(&quot;NameTranslate&quot;)

  objNameTranslate.Init ADS_NAME_INITTYPE_GC, &quot;&quot;
  objNameTranslate.Set ADS_NAME_TYPE_NT4, strDomain &amp; &quot;\&quot; &amp; strObject
  Dim strObjectDN : strObjectDN = objNameTranslate.Get(ADS_NAME_TYPE_1779)

  If Err.Number &lt;&gt; 0 Then strObjectDN = &quot;&quot;

  Set objNameTranslate = Nothing
  On Error Goto 0

  GetObjectDN = strObjectDN
End Function
</pre>
<h3>Usage example</h3>
<pre class="brush: vb;">
strDN = GetObjectDN(&quot;Chris&quot;, &quot;&quot;)
If strDN &lt;&gt; &quot;&quot; Then
  Set objUser = GetObject(&quot;LDAP://&quot; &amp; strDN)
End If
</pre>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indented.co.uk/index.php/2008/10/06/getobjectdn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
