仅使用特定计算机域的installshield创建设置

时间:2017-07-31 07:08:16

标签: wpf installshield setup-project

我正在开发窗口应用程序。我正在使用installshield为此应用程序创建设置。直到一切正常,我能够在任何机器上安装设置。

问题:

出于安全原因,我想限制我对特定域的设置,即假设在我的组织中我们使用的是aaa.com域,那么此设置只能在此域上执行。

如果您需要更多信息,请与我们联系。

2 个答案:

答案 0 :(得分:0)

这是您可以选择的其中一个选项 从注册表中获取域名将为您完成工作 我没有使用InstallShield到那个程度,但我发现this link解释了这个方法 作为参考,我在这里发布了来自所述网站的代码:

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

答案 1 :(得分:0)

基本上,您需要在设置的早期使用自定义操作获取域名,设置属性,然后在启动条件下使用该属性。这有几个关于获取当前域名的答案:

Get the domain name of a computer from Windows API

然而,这种测试在应用程序中通常效果更好。安装时测试意味着用户无法安装然后加入域并运行应用程序。这也意味着用户可以加入域,安装应用程序,然后离开域(甚至可以将笔记本电脑带回家)并继续运行应用程序。那么你提到的“安全理由”是什么?如果域成员身份是应用程序的要求,则将运行时检查添加到应用程序,并让安装在任何地方进行。