I have a Business Base object that I want to allow users to edit if they are in a certain AD group. However, if they are not in the group I would like to prevent them from making changes to the fields (basically mark all the fields read-only). I don't want them trying to make changes and then realize after they hit the Save button that they do not have the correct authorization. Is there a way to do this. Thanks.
Jonathan
So I would need to call AuthorizationRules.AllowWrite for each field on the object. I have about 75 fields on this object. Is that the only way to handle this? Thanks for you help.
Jonathan
Something like this is what I use:
protected override void AddAuthorizationRules()
{
string[] writeRoles = new
string[] { SecurityRole.UberAdmin.ToString()
};
foreach (var
item in this.FieldManager.GetRegisteredProperties())
{
AuthorizationRules.AllowWrite(item, writeRoles);
}
}
Saves a lot of typing.
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: jfreeman
[mailto:cslanet@lhotka.net]
Sent: Friday, November 21, 2008 4:46 PM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] Business Base Authorization Question
So I would need to call AuthorizationRules.AllowWrite for each field on the
object. I have about 75 fields on this object. Is that the only way
to handle this? Thanks for you help.
Jonathan
Thank you Sergey. You rock!
Jonathan
I was able to use the code from Sergey and it works perfectly. However, by turning on Authorization for every control on the form, the screen now takes 30 seconds to load. Before I made the changes it took about 3 seconds. The screen has about 100 fields on it. Is there any way to decrease the load time? I don't think the users are going to like waiting 30 seconds to open this screen. Thanks.
Jonathan
By authorization control do you mean PropertyStatus (WPF) or
AuthorizeReadWrite (WinForms)?
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: jfreeman
[mailto:cslanet@lhotka.net]
Sent: Monday, November 24, 2008 12:49 PM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: Business Base Authorization Question
I was able to use the code from Sergey and it works perfectly.
However, by turning on Authorization for every control on the form, the screen
now takes 30 seconds to load. Before I made the changes it took about 3
seconds. The screen has about 100 fields on it. Is there any way to
decrease the load time? I don't think the users are going to like waiting
30 seconds to open this screen. Thanks.
Jonathan
Sorry. I should have clarified. WinForms AuthorizeReadWrite. Thanks.
Jonathan
I just looked at the class, and it does have a fair amount of
reflection, but I cannot imagine that it would take anywhere near 30 seconds
for 100 fields. Something else I causing the issue, I think. Could
it be that there is something else going on that causes this component to fire
too many times?
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: jfreeman
[mailto:cslanet@lhotka.net]
Sent: Monday, November 24, 2008 1:54 PM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: RE: Business Base Authorization Question
Sorry. I should have clarified. WinForms
AuthorizeReadWrite. Thanks.
Jonathan
I've stepped through my code a few times to make sure and it only calls ResetControlAuthorization one time. I stumped. Any other ideas?
Jonathan
Copyright (c) Marimer LLC