Skip to content

Commit 56ab297

Browse files
committed
AD ingest
Add support for ingest of AD objects
1 parent 423bfb1 commit 56ab297

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

onefuse/admin.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,6 +1593,70 @@ def delete_ingested_scripting_deployment(self, id: str):
15931593
response_json = self.deprovision_mo(path)
15941594
return response_json
15951595

1596+
def ingest_ad(self, policy_name: str, name: str, final_ou: str,
1597+
build_ou: str, state: str = "final",
1598+
security_groups: list = [], template_properties: dict = None,
1599+
tracking_id: str = ""):
1600+
"""
1601+
Ingest an existing AD object to OneFuse - the policy will not execute
1602+
but an object will be added to the OneFuse database.
1603+
1604+
Parameters
1605+
----------
1606+
policy_name : str
1607+
OneFuse AD Policy Name
1608+
name : str
1609+
AD Name
1610+
final_ou : str
1611+
AD Final OU
1612+
build_ou : str
1613+
AD Build OU
1614+
state : str - optional
1615+
AD State. Default is 'final'
1616+
security_groups : list - optional
1617+
List of security groups to add to the AD.
1618+
template_properties : dict - optional
1619+
Dictionary of template properties. Ex: {'key': 'value'}
1620+
tracking_id : str - optional
1621+
OneFuse Tracking ID. If not passed, one will be returned from the
1622+
execution. Tracking IDs allow for grouping all executions for a
1623+
single object
1624+
"""
1625+
# Get Naming Policy by Name
1626+
policy_path = 'microsoftADPolicies'
1627+
policy_json = self.get_policy_by_name(policy_path, policy_name)
1628+
links = policy_json["_links"]
1629+
policy_url = links["self"]["href"]
1630+
workspace_url = links["workspace"]["href"]
1631+
# Ingest AD
1632+
template = {
1633+
"policy": policy_url,
1634+
"workspace": workspace_url,
1635+
"name": name,
1636+
"finalOu": final_ou,
1637+
"buildOu": build_ou,
1638+
"state": state,
1639+
"securityGroups": security_groups,
1640+
"templateProperties": template_properties
1641+
}
1642+
path = "/microsoftADComputerAccounts/ingest/"
1643+
response_json = self.request(path, template, tracking_id)
1644+
return response_json
1645+
1646+
def delete_ingested_ad(self, id: str):
1647+
"""
1648+
Delete an ingested AD object from OneFuse - The deleted object will be
1649+
removed from the OneFuse database without deprovisioning.
1650+
1651+
Parameters
1652+
----------
1653+
id : str
1654+
ID for the AD object
1655+
"""
1656+
path = f"/microsoftADComputerAccounts/{id}/ingest/"
1657+
response_json = self.deprovision_mo(path)
1658+
return response_json
1659+
15961660

15971661
if __name__ == '__main__':
15981662
username = sys.argv[1] # 'OneFuse Username'

0 commit comments

Comments
 (0)