This will convert all attributes that are list with only one item string into simple string. It seems that LDAP always return lists, even when it doesn
        t make sense.

        :param dic:
        :return:

def __compress_attributes(self, dic):
        """
        This will convert all attributes that are list with only one item string into simple string. It seems that LDAP always return lists, even when it doesn
        t make sense.

        :param dic:
        :return:
        """
        result = {}
        for k, v in dic.iteritems():
            if isinstance(v, types.ListType) and len(v) == 1:
                if k not in ('msExchMailboxSecurityDescriptor', 'msExchSafeSendersHash', 'msExchBlockedSendersHash',
                             'replicationSignature', 'msExchSafeRecipientsHash', 'sIDHistory',
                             'msRTCSIP-UserRoutingGroupId', 'mSMQDigests', 'mSMQSignCertificates',
                             'msExchMasterAccountSid', 'msExchPreviousAccountSid', 'msExchUMPinChecksum',
                             'userSMIMECertificate', 'userCertificate', 'userCert',
                             'msExchDisabledArchiveGUID', 'msExchUMPinChecksum', 'msExchUMSpokenName',
                             'objectSid', 'objectGUID', 'msExchArchiveGUID', 'thumbnailPhoto', 'msExchMailboxGuid'):
                    try:
                        result[k] = v[0].decode('utf-8')
                    except Exception as e:
                        logging. error("Failed to decode attribute: %s -- %s" % (k, e))
                        result[k] = v[0]
        return result