No Role present when applying authorization rules

No Role present when applying authorization rules

Old forum URL: forums.lhotka.net/forums/t/1826.aspx


f.scherer posted on Friday, November 24, 2006

Hi,

my login works the same way as in the projecttracker application. I run a stored procedure which returns the in a first resultset the name of the person which logged in and in a second resultset the role in which ther person is in.

m.Parameters.AddWithValue("@username", criteria.Username)

cm.Parameters.AddWithValue("@password", criteria.Password)

Using dr As SqlDataReader = cm.ExecuteReader()

If dr.Read() Then

mName = criteria.Username

mIsAuthenticated = True

If dr.NextResult Then

While dr.Read

mRoles.Add(dr.GetString(0))

End While

End If

Now the role is added to the mRoles list. The problem is that if i want to use the role to set up the page look (also like the example) i always get a "false" when calling "object.caneditobject" for example.

Did somebody have the same problem yet? Thanks for your help in advance,

Frank.

f.scherer replied on Friday, November 24, 2006

Hello??

I had this working in another application. What happened there was that when the IsInRole Mehtod was called the corresponding method in the principal class was adressed.

Public Shared Function CanEditObject() As Boolean

If Csla.ApplicationContext.User.IsInRole("GS") Then

Return True

End If

Return False

End Function

Now it is not adressing the principal class anymore. I donĀ“t know why.

Thanks for your help in advance.

Frank.

 

ajj3085 replied on Monday, November 27, 2006

Did you check the principal and identity to ensure its what you think it is?

f.scherer replied on Monday, November 27, 2006

hi ajj3085

i just found out.... i forgot to add the global.asax file. There i had to add the application_acquireRequestState. After doing that, everthing is working fine now.

Thx,

 

Frank

Copyright (c) Marimer LLC