Skip to main content

Microsoft Teams Organization

Microsoft Teams Organization is a specialized organization type in the JitAuth framework for integrating Microsoft Teams enterprise internal application organization architecture, implementing automatic synchronization and unified management of enterprise organization architecture based on Microsoft Graph API. It handles Microsoft Teams directory synchronization, department structure retrieval, and user authentication, supporting seamless integration with Microsoft Teams workspace and providing enterprise-level permission management and user relationship maintenance capabilities.

The Microsoft Teams organization element hierarchy is Meta (corps.Meta) → Type (corps.MicrosoftTeamsType) → Instance. Developers can quickly create Microsoft Teams organization instance elements through JitAi's visual development tools.

Of course, developers can also create their own Type elements or override the corps.MicrosoftTeamsType element officially provided by JitAi in their own applications to implement their own encapsulation.

Quick Start

Creating Instance Elements

Directory Structure

Recommended Directory Structure
corps/
└── testTeamsOrg/
├── e.json # Element configuration file
└── testTeamsOrg.json # Business configuration file

e.json File

Element Configuration Example
{
"title": "Test Teams Organization",
"type": "corps.MicrosoftTeamsType",
"backendBundleEntry": ".",
"frontBundleEntry": "./testTeamsOrg.json",
"fullName": "corps.testTeamsOrg"
}

Business Configuration File

Business Configuration Example - testTeamsOrg.json
{
"authConfig": {
"tenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"clientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"clientSecret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}

Usage Example

Getting and Using Microsoft Teams Organization
# Get Microsoft Teams organization instance
teams_corp = app.getElement("corps.testTeamsOrg")

# Synchronize organization structure
teams_corp.syncCorp()

# Get root department
root_dept = teams_corp.getRootDept()
print(f"Root department: {root_dept.name}")

Element Configuration

e.json Configuration

Configuration ItemTypeRequiredDescription
titlestrYesOrganization name for display identification
typestrYesFixed value "corps.MicrosoftTeamsType"
backendBundleEntrystrYesBackend entry point, usually "."
frontBundleEntrystrYesFrontend entry point, pointing to business configuration file
fullNamestrYesComplete element name in format "corps.[instance_name]"

Business Configuration File Configuration

Configuration ItemTypeRequiredDescription
authConfig.tenantIdstrYesMicrosoft Azure tenant ID obtained from Azure management console
authConfig.clientIdstrYesClient ID of Azure application
authConfig.clientSecretstrYesClient secret of Azure application

Methods

bulkRegister

Batch register and update user binding relationships for organization members.

Parameter Details

ParameterTypeNative TypeRequiredDescription
corpDataCorpDatadictYesOrganization data object
memberListlistlistNoMember model object list, defaults to None

Return Value

TypeDescription
NoneNo return value

Usage Example

Batch Register Members
teams_corp = app.getElement("corps.testTeamsOrg")

# Get organization data
corp_data = teams_corp.getThirdCorpData()

# Batch register all members
teams_corp.bulkRegister(corp_data)
print("Member registration completed")

getAdmin

Get the administrator ID list for the current organization structure.

Return Value

TypeNative TypeDescription
listlistAdministrator ID list

Usage Example

Get Organization Administrators
teams_corp = app.getElement("corps.testTeamsOrg")
admin_ids = teams_corp.getAdmin()
print(f"Administrator ID list: {admin_ids}")

getClient

Get Microsoft Graph API client instance for communicating with Microsoft Teams platform.

Return Value

TypeNative TypeDescription
MicrosoftTeamsClientobjectMicrosoft Graph API client object

Usage Example

Get Teams Client
teams_corp = app.getElement("corps.testTeamsOrg")
client = teams_corp.getClient()

# Client is used for internal API calls, usually no need to use directly

getCorpInfo

Get organization configuration information.

Return Value

TypeNative TypeDescription
dictdictOrganization configuration information dictionary

Usage Example

Get Organization Information
teams_corp = app.getElement("corps.testTeamsOrg")
corp_info = teams_corp.getCorpInfo()
print(f"Organization information: {corp_info}")

getLocalCorpData

Get complete data of local user pool and enterprise authentication information.

Return Value

TypeNative TypeDescription
dictdictDictionary containing complete organization data including users, departments, roles, etc.

Usage Example

Get Local Organization Data
teams_corp = app.getElement("corps.testTeamsOrg")
local_data = teams_corp.getLocalCorpData()

# Access different types of data
print(f"User list: {local_data['userList']}")
print(f"Department list: {local_data['deptList']}")
print(f"Role list: {local_data['roleList']}")

getRootDept

Get root department information of the organization structure.

Return Value

TypeNative TypeDescription
CorpDeptdictRoot department model object containing basic department information

Usage Example

Get Root Department
teams_corp = app.getElement("corps.testTeamsOrg")
root_dept = teams_corp.getRootDept()

# Access root department attributes
print(f"Department ID: {root_dept.deptId}")
print(f"Department name: {root_dept.name}")
print(f"Organization name: {root_dept.corpFullName}")

getThirdCorpData

Get raw data of Microsoft Teams third-party organization structure.

Return Value

TypeNative TypeDescription
CorpDatadictMicrosoft Teams organization data object containing complete organization structure information

Usage Example

Get Third-party Organization Data
teams_corp = app.getElement("corps.testTeamsOrg")
corp_data = teams_corp.getThirdCorpData()

# Access organization data attributes
print(f"Tenant ID: {corp_data.tenantId}")
print(f"User dictionary: {corp_data.userDict}")
print(f"Department data: {corp_data.deptDict}")

getUserSignature

Get signature information for a specified user.

Parameter Details

ParameterTypeNative TypeRequiredDescription
memberIdstrstrYesUser member ID

Return Value

TypeNative TypeDescription
dictdictDictionary containing signature field

Usage Example

Get User Signature
teams_corp = app.getElement("corps.testTeamsOrg")
signature_info = teams_corp.getUserSignature("member123")
print(f"User signature: {signature_info['signature']}")

initCorp

Initialize Microsoft Teams organization structure. This method is automatically called when creating an instance to synchronize organization data.

Return Value

TypeDescription
NoneNo return value

Usage Example

Initialize Organization Structure
teams_corp = app.getElement("corps.testTeamsOrg")
# Initialization method is automatically called when element is created, usually no need to call manually
teams_corp.initCorp()

offlineMember

Set specified members to offline status without affecting their login in other organization structures.

Parameter Details

ParameterTypeNative TypeRequiredDescription
memberIdListlistlistYesMember ID list

Return Value

TypeDescription
NoneNo return value

Usage Example

Offline Members
teams_corp = app.getElement("corps.testTeamsOrg")
teams_corp.offlineMember(["member123", "member456"])
print("Member offline operation completed")

saveUserSignature

Save signature information for a specified user.

Parameter Details

ParameterTypeNative TypeRequiredDescription
memberIdstrstrYesUser member ID
signaturestrstrYesSignature image link

Return Value

TypeNative TypeDescription
dictdictSuccess return identifier

Usage Example

Save User Signature
teams_corp = app.getElement("corps.testTeamsOrg")
result = teams_corp.saveUserSignature("member123", "https://example.com/signature.png")
print("Signature saved successfully")

setAdmin

Set organization administrators.

Parameter Details

ParameterTypeNative TypeRequiredDescription
memberIdListlistlistYesMember ID list

Return Value

TypeNative TypeDescription
dictdictEmpty dictionary indicates success

Usage Example

Set Organization Administrators
teams_corp = app.getElement("corps.testTeamsOrg")
result = teams_corp.setAdmin(["member123", "member456"])
print("Administrators set successfully")

syncCorp

Synchronize Microsoft Teams organization structure data, including complete synchronization of department structure, user information, and role relationships.

Return Value

TypeDescription
NoneNo return value

Usage Example

Synchronize Organization Structure
teams_corp = app.getElement("corps.testTeamsOrg")

try:
teams_corp.syncCorp()
print("Organization structure synchronized successfully")
except Exception as e:
print(f"Synchronization failed: {e}")

Properties

authConfig

Microsoft Teams authentication configuration information containing key parameters required to connect to Microsoft Graph API.

corpData

Complete configuration data of the organization, containing all element configuration information.

corpFullName

Complete name of the organization element, used to uniquely identify this organization instance in the system.

fullName

Complete name of the organization element, same as corpFullName.

title

Display name of the organization, used for user interface display and logging.

Advanced Features

Automatic Synchronization Mechanism

Microsoft Teams organization automatically executes organization structure synchronization during initialization, ensuring local data remains consistent with Microsoft Teams servers. The synchronization process includes error handling and data integrity validation, supporting efficient synchronization of large-scale organization structures.

Automatic Synchronization Configuration
# Automatically trigger synchronization when creating instance
teams_corp = app.getElement("corps.testTeamsOrg")
# System automatically executes: initCorp() -> syncCorp() -> bulkRegister()

User Identity Binding

Implement unique user identity identification and cross-organization management based on Microsoft Azure user IDs, automatically maintain binding relationships between local users and Microsoft Teams users, supporting dynamic updates of user authentication information and permission inheritance.

User Binding Management
# Automatically handle user binding during synchronization
teams_corp.syncCorp()

# System automatically handles:
# 1. Identify user uniqueness based on Azure user ID
# 2. Create or update local user accounts
# 3. Maintain Microsoft Teams authentication information table
# 4. Set organization member relationships

Permission Integration

Through Microsoft Graph API permission system, achieve deep integration with Azure Active Directory, supporting role-based access control and cross-platform single sign-on, ensuring enterprise data security and compliance requirements.

Permission Integration Example
# Get user's Azure AD role information
teams_corp = app.getElement("corps.testTeamsOrg")
corp_data = teams_corp.getThirdCorpData()

# System automatically handles:
# 1. Synchronize Azure AD user roles
# 2. Map enterprise permission system
# 3. Maintain cross-platform permission consistency
# 4. Support conditional access policies