def from_ldap(entry): adi = MSADDomainTrust() adi.sn = entry['attributes'].get('sn') adi.cn = entry['attributes'].get('cn') adi.distinguishedName = entry['attributes'].get('distinguishedName') adi.objectGUID = entry['attributes'].get('objectGUID') adi.instanceType = entry['attributes'].get('instanceType') adi.whenCreated = entry['attributes'].get('whenCreated') adi.whenChanged = entry['attributes'].get('whenChanged') adi.name = entry['attributes'].get('name') adi.securityIdentifier = entry['attributes'].get('securityIdentifier') adi.trustDirection = entry['attributes'].get('trustDirection') adi.trustPartner = entry['attributes'].get('trustPartner') adi.trustPosixOffset = entry['attributes'].get('trustPosixOffset') adi.trustType = entry['attributes'].get('trustType') adi.trustAttributes = entry['attributes'].get('trustAttributes') adi.flatName = entry['attributes'].get('flatName') adi.dSCorePropagationData = entry['attributes'].get( 'dSCorePropagationData') if adi.securityIdentifier is not None: adi.securityIdentifier = SID.from_bytes(adi.securityIdentifier) if adi.trustType is not None: adi.trustType = TrustType(adi.trustType) if adi.trustDirection is not None: adi.trustDirection = TrustDirection(adi.trustDirection) return adi
def from_ldap(entry): t = MSADTokenGroup() t.cn = entry['attributes'].get('cn') t.distinguishedName = entry['attributes'].get('distinguishedName') t.objectGUID = entry['attributes'].get('objectGUID') t.objectSid = entry['attributes'].get('objectSid') for sid_data in entry['attributes']['tokenGroups']: t.tokengroups.append(SID.from_bytes(sid_data)) return t
def list_x2sid(x): t = [] for s in x: t.append(str(SID.from_bytes(s))) return t
def x2sid(x): return str(SID.from_bytes(x[0]))