MSI installation, get "Full Domain Name" from the registry
Hi
I'm trying to read out the "Full Domain Name" from the server during an installation. And put this into the registry. I have tried to do this from the registry and I have tried to find a property that can do this for me. Other properties like [ComputerName], [INSTALLDIR], [CommonAppDataFolder] etc.. works greate, but I can't seem to find a property that can give me the full domain name.
Anyone with some experience on this?
Regards S
I'm trying to read out the "Full Domain Name" from the server during an installation. And put this into the registry. I have tried to do this from the registry and I have tried to find a property that can do this for me. Other properties like [ComputerName], [INSTALLDIR], [CommonAppDataFolder] etc.. works greate, but I can't seem to find a property that can give me the full domain name.
Anyone with some experience on this?
Regards S
0 Comments
[ + ] Show comments
Answers (8)
Please log in to answer
Posted by:
timmsie
14 years ago
Posted by:
anonymous_9363
14 years ago
I *think* the OP is after the fully-qualified domain name, e.g. ourdomain.ourcompanyname.com: USERDOMAIN only contains the 'ourdomain' part.
@OP, if I'm right, you need to look at some AD interrogation script. Go to the computerperformance site, where there are many AD scripts.
@OP, if I'm right, you need to look at some AD interrogation script. Go to the computerperformance site, where there are many AD scripts.
Posted by:
sabelotodo
14 years ago
Hi guys, thank you for all your replies.
VBScab, you were right I meant the full-qualified domain name, and timmsie I could almost use the [%USERDNSDOMAIN], but the installation prosess is done under "Local System Account" so its not part of the domain.
I will digg a little deeper and post the result if I get it to work:-)
have a nice day!
VBScab, you were right I meant the full-qualified domain name, and timmsie I could almost use the [%USERDNSDOMAIN], but the installation prosess is done under "Local System Account" so its not part of the domain.
I will digg a little deeper and post the result if I get it to work:-)
have a nice day!
Posted by:
anonymous_9363
14 years ago
I'm feeling generous today...
Public blnResult
Public strDomain
Public strFQDomain
Public objRootDSE
blnResult = BindToAD
If Not blnResult Then
WScript.Quit(False)
End If
Function BindToAD()
Dim blnResult_Bind
BindToAD = False
On Error Resume Next
Set objRootDSE = GetObject("LDAP://RootDSE")
If (Err.Number <> 0) Then
Exit Function
End If
strDomain = objRootDSE.Get("DefaultNamingContext")
If (Err.Number <> 0) Then
Exit Function
End If
'// Shouldn't ever be true if no error was returned, but...
If Len(strDomain) = 0 Then
Exit Function
End If
blnResult_Bind = GetFQDNFromNamingContext(strDomain, strFQDomain)
If blnResult_Bind Then
BindToAD = True
Else
If (Err.Number <> 0) Then
Exit Function
End If
End If
On Error Goto 0
End Function
'// ---------------------------------------------------------------------------------
'// GetFQDNFromNamingContext
'// Purpose: Converts a Naming Context into a DNS name
'// Input: strNamingContext e.g. DC=Domain,DC=Company,DC=com
'// Output: FQDN for strNamingContext e.g. Domain.Company.com
'// Returns: True/False
'//
'// Notes: LDAP allows for commas in strings, as long as they are escaped with a \ character.
'// e.g. "CN=Lewis\, Chris"
'// Since commas are not allowed in domain names, there is no parsing for them here.
'// ---------------------------------------------------------------------------------
Function GetFQDNFromNamingContext(ByVal strNamingContext, ByRef strFQDN)
Dim arrDomain
Dim intCount
Dim strTemp
GetFQDNFromNamingContext = False
'// Parse the NC by creating an array with the comma as an array boundry
arrDomain = Split(strNamingContext, ",")
For intCount = 0 To UBound(arrDomain)
'// Add a "." if needed
If Len(strTemp) > 0 Then
strTemp = strTemp & "."
End If
'// Remove the "DC=" and add this item to the temp string
strTemp = strTemp & Mid(arrDomain(intCount), 4)
Next
strTemp = Replace(strNamingContext,"DC=","")
strTemp = Replace(strTemp,",",".")
'// Return the FQDN
GetFQDNFromNamingContext = True
strFQDN = strTemp
End Function
Posted by:
sabelotodo
14 years ago
Posted by:
anonymous_9363
14 years ago
- Add a property to the package called, say, FQDN.
- Assign it a nonsense value, say, NOWHERE.COM.
- In the script, add a check for the FQDN string not being empty. If it is, exit the script. If it's populated, use the Session object's Property method to assign the value to property FQDN:
- You can now use the property FQDN in the installation.
- Assign it a nonsense value, say, NOWHERE.COM.
- In the script, add a check for the FQDN string not being empty. If it is, exit the script. If it's populated, use the Session object's Property method to assign the value to property FQDN:
Session.Property("FQDN") = strFQDomain
- You can now use the property FQDN in the installation.
Posted by:
sabelotodo
14 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.