Who is Participating?

You've mentioned about two different things: ownershisp and ownership permissions. The first one is defined by the Owner field of the security descriptor associated with directory. The second one is an item in in the DACL. In common for each directory you will have to do the following actions:
1) read security descriptor
2) modify it
3) write it back