Re: Translating VB.NET-code into C#.NET + ASP.NET

From: Mike Bright MSP (anonymous_at_discussions.microsoft.com)
Date: 08/07/04


Date: Sat, 7 Aug 2004 13:03:19 +0100

Sjakie, don't have a compiler to hand to check this but:

protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
    if(Request.IsAuthenticated)
    {
        SqlDataReader reader;

        reader =
SqlHelper.ExecuteReader(connection_string,CommandType.StoredProcedure,"rolesForUser",new
SqlParameter("@Username",User.Identity.Name));

        ArrayList roleList = new ArrayList();

        while(reader.Read())
        {
            roleList.Add(reader["Name"]);
        }

        string[] roleListArray = roleList.ToArray(typeof(string));

        HttpContext.Current.User = new
GenericPrincipal(User.Identity,roleListArray);
    }

}

Mmm, as I said no compiler to hand, so if it doesnt compile post back, b.t.w
this isn't really the place to post this, you should post this in the
C# newsgroups.

Regards

Mike Bright MCP, MSP

e:mike.bright@brightweb.co.uk



Relevant Pages