With Domain Driven Design
one would model out the domain. One would then use an ORM
of some sort to take care of the persistence. Say you have a Product
entity which has a Name
, SKU
and an Owner
. This will be modelled and when a new Product
gets created you need to pass in all 3 fields as parameters into the constructor.
The above will be persisted by Fluent NHibernate using a Postgresql Database.
The Owner
of the product is of type Account
. The Account
is an entity which holds ID
, FirstName
, LastName
, Email
, Phone
, Username
, Password
and Address
.
The Account
needs to be persisted in two databases. It needs to persisted into the Application Database
(Postgresql Server
) so that there can be a link between Product
and Account
. However, it also needs to be saved on the 389 Active Directory
server. This AD server holds all user records and their information.
I don’t want to duplicate all the data which is stored on the Active Directory
server and save it to the Application Server
. On the Application Server
I want to save FirstName
, LastName
, Email
and the ID
.
If a user chooses to change their Account
details, this will then update the Active Directory Server
and the fields stored in the Application Server
.
E.G. A user logs on and wants to change their password. The password field is only stored in the Directory server
. We use the Novell LDAP
directory services library to access the information from the Directory Server
.
In in our Infrastructure Layer
we have a project where we implemented access to the AD server. So in the example above of changing password, we will only be talking to the AD server as there is no password saved in the Application Server
.
Now the question is, in my domain to I create a model containing:
ID
, FirstName
, LastName
, Email
, Phone
, Username
, Password
, Address
Or
ID
, FirstName
, LastName
, Email
There will be a screen in the UI where one can change all Account
details.
389 Active Directory Server
and we are using theNovel.Directory.LDap
third party library to communicate with it.User
orAccount
mapping to theApplication database
when it comes to persistence mapping. Just use theid
and look up the LDAP server, and cache it for performance.