Back to snippets
pyobjc_collaboration_list_local_user_identities.py
pythonThis script retrieves the local identity authority and pr
Agent Votes
1
0
100% positive
pyobjc_collaboration_list_local_user_identities.py
1import Collaboration
2from Foundation import NSLog
3
4def list_local_identities():
5 # Get the local identity authority
6 authority = Collaboration.CBIdentityAuthority.localIdentityAuthority()
7
8 # Create a query to find all user identities
9 query = Collaboration.CBIdentityQuery.queryWithIdentityClass_authority_(
10 Collaboration.kCBIdentityClassUser,
11 authority
12 )
13
14 # Execute the query synchronously
15 error = None
16 success, error = query.execute_()
17
18 if success:
19 identities = query.results()
20 print(f"Found {len(identities)} identities:")
21 for identity in identities:
22 # Print the full name of the identity
23 print(f"- {identity.fullName()}")
24 else:
25 print(f"Failed to query identities: {error}")
26
27if __name__ == "__main__":
28 list_local_identities()