#91696 - 2003-03-11 07:58 PM
Ldap Distinguished name
|
James Murdoch
Fresh Scripter
Registered: 2001-12-17
Posts: 20
Loc: Houston Tx.
|
I use Kixtart v3.63 for my logon script and am 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
   
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
|
|
|
|
#91699 - 2003-03-11 08:54 PM
Re: Ldap Distinguished name
|
Howard Bullock
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 ]
|
|
Top
|
|
|
|
#91700 - 2003-03-11 11:01 PM
Re: Ldap Distinguished name
|
Anonymous
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
   
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
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|