Toon posts:

[asp.net]roles werken online niet

Pagina: 1
Acties:

Verwijderd

Topicstarter
Lokaal had ik een systeem geschrevend dat er twee roles waren: user en admin.
ik heb één admin toegevoegd in tbl klanten voor de website aan te passen.
Nu heb ik in mijn code de volgende regel
Visual Basic .NET:
1
2
3
  If HttpContext.Current.User.IsInRole("admin") Then
                Response.Write("<a href='producten2.aspx'>Website aanpassen</a>")
            End If

(die producten2.aspx is ook beveiligd via web.config)
Nu het rare is, lokaal wordt deze regel wel geschreven als admin is ingelogd en online NIET!
waar moet ik nu de fout gaan zoeken? ik word er zot van....

Verwijderd

Kun je ook eens posten wat er gebeurt bij login?
Wat heb je zelf al geprobeerd?
Ben je hier iets mee?

[ Voor 56% gewijzigd door Verwijderd op 03-09-2003 10:27 ]


Verwijderd

Topicstarter
dat artikel hebt ik gevolgt toen!
wat ik al heb geprobeerd: online kan je niet veel doen hé want je kan niet debuggen. Wel mijn code offline overlopen om te zien of er iets mis was
mijn login ziet er als volgt uit:
Visual Basic .NET:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
...
  Dim customerId As String = accountSystem.Login(email.Text, password.Text)
            Dim roles As String = accountSystem.getRoles(customerId)

            If customerId <> "" Then
      Dim customerDetails As ahbClass.ahbshop.CustomerDetails = accountSystem.GetCustomerDetails(customerId)
   Dim ticket As FormsAuthenticationTicket = New FormsAuthenticationTicket(1, customerId, DateTime.Now, DateTime.Now.AddMinutes(30), RememberLogin.Checked, roles, FormsAuthentication.FormsCookiePath)
                Dim hash As String = FormsAuthentication.Encrypt(ticket)
                Dim cookie As HttpCookie = New HttpCookie(FormsAuthentication.FormsCookieName, hash)
                Response.Cookies.Add(cookie)
                Dim returnurl As String = Request.QueryString("returnurl")
                If returnurl Is Nothing Then
                    returnurl = "home.aspx"
                End If
                Response.Redirect(returnurl)
                System.Web.Security.FormsAuthentication.RedirectFromLoginPage(customerId, RememberLogin.Checked)

  • whoami
  • Registratie: December 2000
  • Laatst online: 22:54
Zorg je ervoor dat die roles aan de user toekend worden, en hoe doe je dat?
Heb je hier wat aan?

https://fgheysels.github.io/


Verwijderd

Topicstarter
roles worden toegekend aan user:
Visual Basic .NET:
1
2
3
4
5
6
7
8
9
10
11
12
13
    Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires upon attempting to authenticate the use
        If Not HttpContext.Current.User Is Nothing Then
            If HttpContext.Current.User.Identity.IsAuthenticated Then
                Dim id As FormsIdentity = CType(HttpContext.Current.User.Identity, FormsIdentity)
                Dim ticket As FormsAuthenticationTicket = id.Ticket
                Dim userdata As String = ticket.UserData
                Dim roles As String() = userdata.Split(",")
                HttpContext.Current.User = New GenericPrincipal(id, roles)

            End If
        End If
    End Sub

  • whoami
  • Registratie: December 2000
  • Laatst online: 22:54
Ben je wel zeker dat de data in je DB van je online versie goed is?

https://fgheysels.github.io/


Verwijderd

Topicstarter
ja want ik heb ze net gedownload
daar staat in:
bij de admin record:
roles: "admin"

Verwijderd

Topicstarter
ok
fout gevonden
global.asax moet ik in root van webproject staan
*zucht*
Pagina: 1