Fuego.Fdi : DirOrganizationalUnit

The DirOrganizationalUnit component is used to create Organizational Units and retrieve information about Organizational Units in the Directory.

Organizational units are typically departments or divisions within an organization. Organizational units can be organized in a hierarchy.

You can associate any data with a particular organizational unit by using the DirOrganizationalUnit.store*Property() set of methods. To retrieve previously-stored data, use the DirOrganizationalUnit.retrieve*Property() set of methods.

Example 1

The following example creates an Organizational Unit. Before it creates the Organizational Unit, it fetches the Parent Unit.

session = DirectorySession.currentEngineSession
 
// Load the top-level (root) org unit
rootOU = DirOrganizationalUnit.fetchRoot(session : session)

// Create an OU for "boston"
bostonOU = create(rootOU, session : session,
	name : "Boston", description : "Boston Offices")

// Create two more OUs under "boston":
bostMarkOU = create(bostonOU, session : session,
	            name : "boston_marketing", description : "Boston Marketing OU")

bostSaleOU = create(bostonOU, session : session,
	            name : "boston_sales", description : "Boston Sales OU")

Example 2

The following example checks the visibility between Organizational Units. Organizational Units form a tree, in which the top-level unit is the root. Unit A is visible to Unit B if A is in the path from B to the top-level Unit (root of the tree) or if B is in the path from A to the top-level Unit.

// Is Dallas Visible to Boston ? (false)
DirOrganizationalUnit.areVisible(ou1 : "Dallas", ou2 : "Boston")

// Is Boston Visible to Boston/Sales ? (true)
DirOrganizationalUnit.areVisible(ou1 : "Boston", ou2 : "Boston/Sales")

Example 3

The following example retrieves all Organizational Units:

allOUs = DirOrganizationalUnit.fetchAll(dir : session)
for each orgUnit in allOUs do
   logMessage "OU:"+orgUnit.displayName
end

Example 4

The following example retrieves the children of a particular Organizational Unit:

session = DirectorySession.currentEngineSession
bostonOU = DirOrganizationalUnit.fetch(session : session, id : "Boston")

ousUnderBoston = fetchChildren(bostonOU)
for each ouC in ousUnderBoston do
    logMessage "OU under Boston: "+ouC.displayName
end

Example 5

The following example updates information about an Organizational Unit:

session = DirectorySession.currentEngineSession
bostonSalesOU = DirOrganizationalUnit.fetch(session : session, id : "boston_sales")

bostonSalesOU.description = "Boston/Sales department"
update bostonSalesOU
Related reference
Fuego.Fdi : DirectorySession
Fuego.Fdi : DirHumanParticipant
Fuego.Fdi : DirOrganizationalRole