Hi,
I'm looking at creating an account management system for our Windows AD and
have a generic OO design question.
I have a user class (user.cs) which will serve two purposes. First, it will
store information from some form of user input and be sent to the AD service
class (ad.cs) to create or modify an account. Second, it will be used by
ad.cs to store information retrieved from the AD and returned to the user
for display or manipulation or something (ie. user.java would be a Java
EJB).
The problem is that access to user.cs's properties and methods should be
different for ad.cs and the user input. For instance, the OU property
should be read/write for ad.cs but read only for the user. The DisplayName
has some business logic to restrict what the user can write to that
property, but ad.cs should be able to write anything (<shameful>not all of
our accounts apply all of our business rules</shameful>).
I had considered splitting user.cs class. Creating an internal account.cs
base class in a Windows namespace then deriving a public user.cs in the
ActMgmt namespace. That could give ad.cs (also in the Windows namespace)
all the permissions it needs without exposing itself to the user while
applying business logic to the user.cs. Unfortunately, this approach isn't
allowed by the C# compiler; it yields and inconsistent accessibility error
because the base class is less restrictive than the derived.
It seems to me that this would be a fairly generic programming issue so some
of you full-time programming guru's may have some good advice on this. A
web link would be great.
Thanks!
bob
|