Function BindDN(Line)
	Const E_ADS_PROPERTY_NOT_FOUND  = &h8000500D
	Const LDAP_NO_SUCH_OBJECT = &h80072030
	Dim strDN, objComputer, strComptName
BEGIN COMMENT
	? Use the Instr function to get the input file?s Distinguished
	? Name heading for writing to the first column in the report.
END COMMENT
	strDN = Mid(Line,2,Instr(1,Line,Chr(34) & Chr(44))-2)
BEGIN COMMENT
	? Bind to the computer in AD.
END COMMENT
	On Error Resume Next
	Set objComputer = GetObject(«LDAP://» & strDN)
	If Err.Number = LDAP_NO_SUCH_OBJECT Then
BEGIN COMMENT
		? The GetObject method was unable to bind to the specified
		? DN, which probably means the computer isn?t listed in AD.
END COMMENT
? BEGIN CALLOUT A
		BindDN = strDN & «||None||Invalid»
? END CALLOUT A
	Else
BEGIN COMMENT
		? Get the computer?s dNSHostName.
END COMMENT
		strComptName = objComputer.Get(«dNSHostName»)
BEGIN COMMENT
		? If the dNSHostName attribute is set, use it for the registry update.
END COMMENT
		If Err.number <> E_ADS_PROPERTY_NOT_FOUND Then
? BEGIN CALLOUT B
			BindDN = strDN & «||» & strComptName & «||Host»
? END CALLOUT B
		Err.Clear
BEGIN COMMENT
		? If the dNSHostName attribute isn?t set, use the
		? cn attribute for the registry update.
END COMMENT
		Else
			strComptName = objComputer.Get(«cn»)
? BEGIN CALLOUT C
			BindDN = strDN & «||» & strComptName & «||NetBIOS»
? END CALLOUT C
		End If
	End If
	Err.Clear
	On Error GoTo 0
End Function