【问题标题】:Create setup using installshield for particular computer domain only仅为特定计算机域使用 installshield 创建设置
【发布时间】:2017-07-31 07:08:16
【问题描述】:

我正在开发窗口应用程序。我正在使用 installshield 为这个应用程序创建设置。到那时一切正常,我可以在任何机器上安装设置。

问题:

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

如果您需要更多信息,请告诉我。

【问题讨论】:

  • 安装前能否检查一下注册表中的域?
  • 好的,我正在调查你的答案,如果它会起作用,请告诉你..

标签: wpf installshield setup-project


【解决方案1】:

这是您可以选择的选项之一。
从注册表中获取域名将为您完成这项工作。
我没有使用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

【讨论】:

    【解决方案2】:

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

    Get the domain name of a computer from Windows API

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

    【讨论】:

    • 感谢@PhilDW 的回复。因此,使设置安全的最佳方法是只有授权成员才能安装或使用。随时欢迎您提出宝贵意见和建议。
    • 出于我提到的原因,我的建议是将域检查放在应用程序中,并且链接显示了要使用的代码类型。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-07
    • 1970-01-01
    • 2016-10-28
    • 1970-01-01
    • 1970-01-01
    • 2014-06-02
    相关资源
    最近更新 更多