 |
|
 |
Hi,
I thinking of using the strong name solution to the security problem my app is having because it is being deployed in a shared network server.
I create the strong name, added to my assembly file, and now plan on creating code group on the network server.
2 questions:
Do I need to reboot network server after I make code group change?
Do I still need to create a MSI script to be run on each client server?
Thanks in advance,
mccalla
|
|
|
|
 |
|
 |
Sorry I am just responding now. I did not get the notification when you posted your question.
I would guess you have already figured out the answers to you questions.
You asked:
Do I need to reboot network server after I make code group change?
No, there is no need to reboot the network server after the code group change.
Do I still need to create a MSI script to be run on each client server?
Yes, each client needs to trust the strong name so it will have the proper trust level when it accesses something on the network share.
Ben
|
|
|
|
 |
|
 |
We have a web application,from there we want to invoke an exe.So it results in the same security error.Even though we had done this the security problem occurs.Any Solutions??? C.Babu
|
|
|
|
 |
|
 |
Most of the time, if you still get the security error it is one of two things.
First, you didn't create the msi script correctly.
Second, you don't have admin rights on the PC that you ran the MSI script on.
My guess is that you don't have admin rights on the PC you ran the MSI script on. You don't get any indication that the MSI script didn't work. It just runs, but when you are not the admin it can't do anything since you don't have rights.
I hope that helps.
Thanks,
Ben
|
|
|
|
 |
|
 |
Hi there,
I've followed the process as you've described, created the code group, then created the MSI, and ran the MSI on a machine with administrator rights, and the could see the entry in the security.config file, and the application on the network share ran perfectly.
Then I ran the MSI on a machine without administrator rights. I received no errors when the installation ran. The applicatition on the share still failed with a security error, and when I checked the security.config file on this machine, there was no entry for the new code group to be found.
Should I expect this to work?
|
|
|
|
 |
|
 |
Hello,
When you run the MSI script on the PC you must run it as an admin. Otherwise the script really doesn't do anything. There are some active directory ways of pushing out msi scripts to all PC's. A Network admin would probably have a better idea how to do that. Hope that helps.
Ben
|
|
|
|
 |
|
 |
Thanks for putting this together Ben. Definitely helps. Figured I'd add an extra piece to the puzzle for anyone interested.
This piece of code (which I cannot claim for myself) allows you to programmatically add your new codegroup to the machine policy settings. If you host your app on a server, throw this into a simple app and run it on each workstation using your method of choice.
Dim publicKey As Byte() = {0, 36, 0, 0, 4, 128, 0, 0, 148, ..., 41, 17, 223, 92, 180, 207, 31, 78, 6, 193}
Dim machinePolicyLevel As PolicyLevel = Nothing
Dim ph As System.Collections.IEnumerator = SecurityManager.PolicyHierarchy()
While ph.MoveNext()
Dim pl As PolicyLevel = CType(ph.Current, PolicyLevel)
If pl.Label = "Machine" Then
machinePolicyLevel = pl
Exit While
End If
End While
If machinePolicyLevel Is Nothing Then
Return
End If
Dim codeGroup As CodeGroup
Dim machineCodeGroupRoot As CodeGroup
For Each codeGroup In machinePolicyLevel.RootCodeGroup.Children
If codeGroup.Name = "My Group" Then
MsgBox("Permissions Exists")
Return
End If
Next codeGroup
Dim permSet1 = New NamedPermissionSet("FullTrust")
Dim key As New StrongNamePublicKeyBlob(publicKey)
Dim membership1 = New StrongNameMembershipCondition(key, Nothing, Nothing)
Dim policy1 As New PolicyStatement(permSet1)
Dim codeGroup1 = New UnionCodeGroup(membership1, policy1)
codeGroup1.Description = "This is a description."
codeGroup1.Name = "My Group"
machinePolicyLevel.RootCodeGroup.AddChild(codeGroup1)
SecurityManager.SavePolicy()
Enjoy! And I too am a born again Christian who has accepted Christ as my Savior and He is the ONLY way to Heaven. Thanks for being bold Ben!
|
|
|
|
 |
|
 |
Thanks for posting this code. I am sure there is an assumption that the user running this code is an Admin on the box. It is nice to know another way of doing things.
In Christ,
Ben
|
|
|
|
 |
|
 |
Yes, you are correct. An admin will need to run this. Thanks for clarifying that. We're a pretty large installation and we'll probably push this out via SMS or however the windows admins will want to do it.
|
|
|
|
 |
|
 |
Great article!
For people using VS 2005, there is actually now an easier way to sign an Assembly.
Just open the property window for the project, and click on the the Signing tab. Then select "Sign the assembly", and choose the key file from the dropdown list.
There is are also options for specifying a password for the key file and for delayed signing on this tab.
Just thought I would mention this..
|
|
|
|
 |
|
 |
I'm glad you mentioned this. Thought I'd add my 2 cents regarding what I found. It appears that there is a number of differences with the security between 2003 and 2005. Using a couple highly simplistic apps, the one's created with 2003 would not run at all (without adding security), but the 2005 apps would. For example, I had an app that I created in VB.NET 2003 which had two forms containing some buttons and text boxes and that was it. I compiled it and attempted to run it from a shared network drive. It failed to run (debug stated it was failing at the end of sub new(). Interesting. Then I converted it to 2005 and attempted to run it from the same network drive. It actually ran. Very interesting. (I hope I explained that ok).
So what does this mean? Probably not much, but thought I'd share it with you. M$ definitely has revamped a lot of the security settings in 2005/2.0. I'm still going to have to stick with 2003 since we don't have framework 2.0 on all clients. However, I'm having to write to a temp file on the client, so I'm going to have to have a codegroup anyway.
Blessings,
Mark
|
|
|
|
 |
|
 |
Hi everyone
I'm totally new to .Net and the company I work for are now making the move from vb6 to vb.Net. The code using the OpenFiles.exe sound more or less like what we need but it's a little over the top for me at this moment.
Basically I want to create a textfile log of all shared files accessed (over the network), when, for how long and by whom. So far your code is the closest I got to a solution.
Any suggestions or useful links I can follow?
Thanks!
woNTioD - 3vlndl3
|
|
|
|
 |
|
 |
Well, unfortunatly the openfiles.exe will only tell you that someone is in the files. You would probably need to write something that kept track of when the user first accessed the file and when they got out.
If you install the openfiles service on the network file share it will start to produce an XML file (which is a .net dataset) every minute that contains who is in what file. They overwrite after 60 minutes. The client app I wrote to go with it reads in the xml file and displays it.
So if you want to know when someone started looking at a file and how long they had it open, you would have to write some code that would process the xml file outputs and write out the correct txt files you need.
Sorry if this wasn't very helpful, I suppose sooner or later you will have to dig in and learn .net.
Ben
|
|
|
|
 |
|
 |
Why would you mix religion with technology in your article.
How lame would it sound if i put the following at the end of every one of my emails.
On a personal note I am a born again Muslim, if anyone has any questions about what it means to have a right relationship with Allah or if you have questions about who Mohammed is, send me an e-mail. spiritual_solicitor@inyourface.com My relationship with Allah gives purpose and meaning to my life, because of course, my relationship with my wife, kids, family, friends, and peers isn't enough.
|
|
|
|
 |
|
 |
Dear Anonymous,
Thanks for your note. I am sorry if my personal bio offends you. Still I make no excuses for it. The whole point of having a personal bio is so that you get to know someone a bit better. I can honestly say that as much as I enjoy programming, my relationship with God is so much more important. Yes even more then my wife, kids, friends. And you are correct that I believe that as much as I love and care for (wife, kids, friends) they can never satisfy me the way my relationship with God does.
Let me ask you this. If you found the Truth and it changed your life, wouldn't you want to share it with others? How could you keep your self from sharing what has happened in your life. I have always from an early age needed to know what is life all about? What is my purpose? I can tell you that only by a right relationship with God have I come to know True Peace and fulfillment. I can't help but say something so that others may know this same joy.
I wish you a blessed Ramadan and pray that as you seek God, He will reveal to you who Isa truly is, Son of God and Savior.
Ben
|
|
|
|
 |
|
 |
I've tried this with a small Managed C++ console app. I could never get the importing of the strong name to work. I allways get a error complaining about an invalid assembly. However running:
sn -v myprog.exe
Says the assembly is valid!
Has anyone else run into this?
Thanks.
Nigel Atkinson
"Land a'hoy!" * CRASH * "I should av said that sooner eh?" - Eckles, The Goon Show
|
|
|
|
 |
|
 |
First I should tell you up front that my C++ skills leave something to be desired. So take my advise for what it is worth, which is pretty much just guessing. Anyway, I was guess that the part of the C++ code where you attach the strong name key to the C++ assembly isn't quite working. There you have it my best guess.
Ben
|
|
|
|
 |
|
 |
Thanks for your reply. I havn't got to the bottom of the problem yet, however I have got the strong name working. As far as I can tell, the key pair I generated is being compiled into the C++ program correctly, as the process is almost identicle as VB and C#.
What I did was make a very simple VB console program that does nothing except output some text and add the same key pair I was using for the C++ program. Then I used this exe to import the key pair into mscorcfg.
This worked, and now both the VB and C++ app work as expected. I think (not totally sure) all mananged C++ programs have an unmanaged stub, which might prevent importing the strong name key pair?
Anyhow I hope this helps others.
Thanks
Nigel Atkinson
"Land a'hoy!" * CRASH * "I should av said that sooner eh?" - Eckles, The Goon Show
|
|
|
|
 |
|
 |
I am glad you figured the strong named key thing out. I am sure your hard work will benefit others. Thanks for letting us know what happened.
Ben
|
|
|
|
 |
|
 |
I have developed a Windows.Forms.UserControl, which is embeded in a Web page in Internet Explore. To work this control properly I have to create a group in Runtime Security Policy and give this group a permission set with granted 'Allow calls to Unmanaged Code' and 'Assert any permission that has been granted' permissions. When the Membership Condition is set with URL condition type, my control works as expected. But the case isn't the same when I have used the Strong Name condition type. IE just not activate the control, without any error messages or exceptions. In order to sign my assembly with strong name, I have created key pair with 'sn -k keypair.snk' command line, and added '[assembly: AssemblyKeyFile(@"..\..\keypair.snk")] line to my source code. After that I have verified the signature with 'sn -f ' comman line and it has told me that my assembli is valid. Can anybody explain me what is wrong?
|
|
|
|
 |
|
 |
First I will tell you straight up that I don't know the answer. Still I have some thoughts. Even though the assembly has a strong name you still need to create a code group where the strong name key is marked as trusted. Next it seems that every user that might access the page that uses that control may need to have that code group installed. If it is not running there then the web server itself would probably need the code group for the assembly to be marked at trusted.
Anyway, those are my thoughts. I hope they help you find the solution.
Ben
|
|
|
|
 |
|
 |
Ben, thanks for the replay,
I have found the solution in
http://www.dotnet247.com/247reference/msgs/18/92236.aspx
Namely, adding the attribute
[assembly: AllowPartiallyTrustedCallers()] in AssemblyInfo.cs of my Control has resolved the problem. Really I don't know exactly why. Not yet.
Georgi
|
|
|
|
 |
|
 |
I am new to vb.net but have written apps in vb6 which run from a central server. However have tried both part 1 and 2 suggestions without success. The debugging routine always points to the line which accesses an ini file. This file lives in the same folder on the server as the .exe
I need to use ini files to allow other users to easily edit settings. The registry is not an option.
What else do I need to do?
|
|
|
|
 |
|
 |
I guess first I need to ask if you are working on your local pc? If you are then you need to double check the code group you set up. You probably have an error. You may not have set full trust. You might have not put a * in the network path name.
Now if it is working on your local PC, but not on a users PC. The issues I have seen are:
.net framework not loaded on a users PC. Load the .net framework.
They ran the MSI script, but it didn't add the code group. This usually happens when the user does not have admin rights to their own PC. Someone with admin rights must run the MSI script for them. You can use the RUNAS. I have also seen where after running the MSI script the User needs to log out and then log back in again.
I hope that is helpful.
Ben
|
|
|
|
 |
|
 |
thanks for the speedy reply
I cannot get it to work from a network drive back to my development laptop as well as to another client PC. All systems have the .net framework.
In the code group I used file://ip address/folder/* and also tried file://ip address/folder/applicationname.exe
I have full access to the network folder as I copy the .exe there.
I have double checked and full trust is set and I have admin rights on my laptop.
mike
|
|
|
|
 |