Format a LDAP attribute
(self, name, value, crop=False)
| 1878 | return self.new("addchild") |
| 1879 | |
| 1880 | def _format_attribute(self, name, value, crop=False): |
| 1881 | """ |
| 1882 | Format a LDAP attribute |
| 1883 | """ |
| 1884 | if isinstance(value, list): |
| 1885 | # It's a list. |
| 1886 | return ";".join(self._format_attribute(name, v, crop=crop) for v in value) |
| 1887 | elif name == "objectSid": |
| 1888 | return WINNT_SID(value).summary() |
| 1889 | elif isinstance(value, bytes): |
| 1890 | # Catch-all for bytes values |
| 1891 | value = value.hex() |
| 1892 | else: |
| 1893 | # Catch-all |
| 1894 | value = str(value) |
| 1895 | # If cropping is enabled and requested, crop |
| 1896 | if crop and self.crop_output.get() and len(value) >= 80: |
| 1897 | return value[:80] + "... (%so)" % len(value) |
| 1898 | return value |
| 1899 | |
| 1900 | def _parse_attribute(self, name, value): |
| 1901 | """ |
no test coverage detected