Page 1 of 1 1
Topic Options
#91696 - 2003-03-11 07:58 PM Ldap Distinguished name
James Murdoch Offline
Fresh Scripter

Registered: 2001-12-17
Posts: 20
Loc: Houston Tx.
I use Kixtart v3.63 for my logon script and am [Smile] not ready to upgrade that, but I need to determine the fully qualified domain name of a machine as it is used to logon to the network.

I am wanting to have Kixtart pass the common name to a VBS script that would get the fully qualified domain name from LDAP, but need to know how to directly access that in the AD, using LDAP, from the common name.

Any ideas?

Top
#91697 - 2003-03-11 08:17 PM Re: Ldap Distinguished name
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
This is untested but might try this under 3.63:

code:
break on 

$SystemInfo = OleCreateObject("AdSystemInfo")

? OleGetProperty($SystemInfo,"ComputerName")

exit 1

only works natively under 2K and XP - may work under NT and 9x with DSCLIENT installed.

-Shawn

Top
#91698 - 2003-03-11 08:38 PM Re: Ldap Distinguished name
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ermmm - maybe not exactly what your looking for but something to chew on ...
Top
#91699 - 2003-03-11 08:54 PM Re: Ldap Distinguished name
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
On a windows 200 computer you can look at this registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DomainCache

for a list of known domains.

Or you can look here: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters It is not an LDAP name but you could parse it and build the name you want.

[ 11. March 2003, 20:55: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#91700 - 2003-03-11 11:01 PM Re: Ldap Distinguished name
Anonymous
Unregistered


3.63 is definitely not the way you want to go about doing this, but if you must this will get you started. It doesn't work right now, but it'll give you an idea of what you need to do:

code:
$objRoot = OleGetObject(0, "LDAP://RootDSE")
$strDefaultDomainNC = OLECALLFUNC($objRoot, "Get", "s", "DefaultNamingContext")
? $strDefaultDomainNC
sleep 2
$ComputerName = "CN=ComputerName"

If $strDefaultDomainNC = ""
? "Error. Did not get the Default Naming Context"
EndIf

$strADSQuery = "SELECT Name, AdsPath FROM 'LDAP://" + $strDefaultDomainNC + "' WHERE Name = '" + $ComputerName + "'"

$objADOConn = OlecreateObject("ADODB.Connection")

OlePutProperty($objADOConn, "Provider", "s", "ADsDSOObject")
OleCallProc($objADoConn, "Open", "s", "Active Directory Provider")

;***********************
;This is where it gets sticky. Good luck.

;$objQueryResultSet = OleCreateObject("ADODB.Recordset")
$objQueryResultSet = OleCallFunc($Connection, "Execute", "s", "$strADSQuery")


? OleGetProperty($objQueryResultSet, "EOF")

If OleGetProperty($objQueryResultSet, "EOF")
? "Computer " + $ComputerName + " was not found")
EndIf

While Not OleGetProperty(objQueryResultSet, "EOF")
? "Path = " + OleGetProperty($objQueryResultSet.Fields("AdsPath") ; You'll need the 3.63 code to get a field recordset value, you can find an example somewhere on the board.
OleCallProc(objQueryResultSet, "MoveNext")
Loop


Top
#91701 - 2003-03-11 11:19 PM Re: Ldap Distinguished name
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
When you get around to upgrading Kix, do to either 4.12 or 4.20+

stay away from 4.10 and 4.11
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.045 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org