How can I get a client to easily trust an assembly?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a no touch deployment smart client app. In order to get it to run on any machine, I have to run the "Trust an Assembly" wizard from that machine and set full control for my strong named assembly. Is there a way to automate this process? I don't want to have to give out a long instruction list on setting up the app, that's why I want to use no touch deployment. Is there a way to make this easier? Thank you.
 
1) There is a commandline tool (installed when the framework is installed) 'caspol.exe' which does exactly the same as the wizard.
This tool is in the folder %windir%\Microsoft.NET\Framework\your latest framework version (eg. v1.1.4322)
2) The following excerpt adjust security from code:

DimmachinePolicyLevel As PolicyLevel = Nothing
Dim ph As IEnumerator = SecurityManager.PolicyHierarchy
Do While ph.MoveNext
Dim p1 As PolicyLevel = CType(ph.Current, PolicyLevel)
If p1.Label = "Machine" Then
machinePolicyLevel = p1
Exit Do
End If
Loop

If machinePolicyLevel Is Nothing Then Return
' Intranet
Dim permissionSet As PermissionSet = New NamedPermissionSet("FullTrust")
Dim membership As IMembershipCondition = New UrlMembershipCondition("http://<some ip address>/<some directory>/*")

Dim policy As PolicyStatement = New PolicyStatement(permissionSet)
Dim codeGroup As CodeGroup = New UnionCodeGroup(membership, policy)
codeGroup.Description = "FullTrust permissions for http://<some ip address>/<some directory>/"
codeGroup.Name = "XXX"

' Internet
Dim permissionSet2 As PermissionSet = New NamedPermissionSet("FullTrust")
Dim membership2 As IMembershipCondition = New UrlMembershipCondition("http://<some ip address>/<some directory>/*")
Dim policy2 As PolicyStatement = New PolicyStatement(permissionSet2)
Dim codeGroup2 As CodeGroup = New UnionCodeGroup(membership2, policy2)
codeGroup2.Description = "FullTrust permissions for http://<some ip address>/<some directory>/"

codeGroup2.Name = "XXX"

machinePolicyLevel.RootCodeGroup.AddChild(codeGroup)
machinePolicyLevel.RootCodeGroup.AddChild(codeGroup2)
SecurityManager.SavePolicy()
 
Back
Top