0

I am working on window application. I am using installshield to create setup for this application. Till then everything is working fine i am able to install setup on any machine.

Problem:

For security reason i want to restrict my setup for particular domain only i.e suppose in my organization we are using aaa.com domain then this setup will only able to execute on this domain.

Please let me know if you need more information.

Sunny
  • 3,185
  • 8
  • 34
  • 66

2 Answers2

0

This is one of the options you can take.
To get the domain name from registry would do the job for you.
I have not used InstallShield to that extent but I have found this link that explains the method.
For the reference I am posting the code from said website here:

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
XAMlMAX
  • 2,268
  • 1
  • 14
  • 23
0

Basically you need to get the domain name early in the setup with a custom action, set a property and then use that property in a launch condition. This has several answers about getting the current domain name:

Get the domain name of a computer from Windows API

However this is the kind of test that often works better in the application. An install-time test means that the user cannot install and then join the domain and run the app. It also means the user can join the domain, install the app, and then leave the domain (maybe even take a laptop home) and continue to run the app. So what is the "security reason" you mention? if domain membership is a requirement of the application then add a run time check to the application and let the install happen anywhere.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • Thanks @PhilDW for your reply. So what will be the best way to make a setup secure means only authorized member can install or use. Always welcome to your valuable advice and suggestions. – Sunny Aug 04 '17 at 03:29
  • My suggestion is to put the domain check in the app for the reasons I mentioned, and the link shows the kind of code to use. – PhilDW Aug 07 '17 at 17:51