Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

C# DLL an Windows Security


  • Please log in to reply
2 replies to this topic

#1 ferroariel


    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 28 April 2009 - 06:20 AM

Hi u all!!!

I have a website, dedicated to beauty products for women, ok? Sometime ago a friend of mine told me "hey! why don´t you send that info through MSN?". I liked that, so I downloaded an autoresponder code from here:


So I simply added this routine to get search results from my site:

public string getSiteSearchResults()
        {   string reader = "";
            string search = "[the received message text goes here]";
            string url = "[the URL of my website search page]?query="+ search;
                WebPermission pWeb = new WebPermission(NetworkAccess.Connect, url);
                SecurityPermission pSec = new SecurityPermission(SecurityPermissionFlag.AllFlags);
                PermissionSet set = new PermissionSet(PermissionState.None);
                HttpWebRequest URLReq = (HttpWebRequest)WebRequest.Create(url);                
                URLReq.Credentials = CredentialCache.DefaultCredentials;
                URLReq.AuthenticationLevel = System.Net.Security.AuthenticationLevel.None;
                URLReq.AllowAutoRedirect = true;
                URLReq.Timeout = 60000;                
                HttpWebResponse URLRes = (HttpWebResponse)URLReq.GetResponse();                
                Encoding enc = Encoding.GetEncoding(1252); 
                StreamReader sStream =   new StreamReader(URLRes.GetResponseStream(), enc);            
                reader = sStream.ReadToEnd();                
            catch (Exception ex)
                reader = ex.Message ;
            return (reader);                

So when somebody asks for some product, the addin (working on one of my pcs) do a search on my site, get the results and send ´em in response as plain text.

Well, instead of that, all I get is this:
Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I read about gacutil, regasm, caspol, trust zones, trusted assembly, security zones...... but don´t have a clue where to start to get rid of this thing, really.

Any help is truly appreciated

Txs in adv

  • 0

#2 ArekBulski


    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 480 posts

Posted 28 April 2009 - 10:12 AM

Hmm, I have really no idea how those security permissions work. I googled and found this page, where I found reference to this article. Is this a good hint?
  • 0

#3 ferroariel


    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 28 April 2009 - 12:37 PM

Txs for your post ArekBulski!!
Well, I'll give a try to that doc, but think I've already did
Somebody talked me to use the WebClient object, which I haven't tried so far, will see...
  • 0

Also tagged with one or more of these keywords: authentication

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download