Comments (2)
This is the critical part:
for record in data:
# If the dn is requested, return it along with the payload,
# otherwise ignore it.
for key in record[1]:
if isinstance(record[1][key][0], bytes) and key != 'objectSid':
value = record[1][key][0].decode('utf-8')
record[1][key] = [value]
if self._dn_requested:
merged_records = {'dn': record[0]}
merged_records.update(record[1])
yield merged_records
else:
yield record[1]
member list is > 1, so it converts the first member only, we need to check the length of the list, as for members it is not always 1, as for the other attributes. My solution would be:
for record in data:
# If the dn is requested, return it along with the payload,
# otherwise ignore it.
for key in record[1]:
if len(record[1][key]) > 1:
for i, item in enumerate(record[1][key]):
if isinstance(item, bytes) and key != 'objectSid':
value = item.decode('utf-8')
record[1][key][i] = value
else:
if isinstance(record[1][key][0], bytes) and key != 'objectSid':
value = record[1][key][0].decode('utf-8')
record[1][key] = [value]
if self._dn_requested:
merged_records = {'dn': record[0]}
merged_records.update(record[1])
yield merged_records
else:
yield record[1]
I'll create a pull request, please modify as needed.
from nsscache.
as stands of now we can use one of the follwoing:
for key in record[1]:
for i, item in enumerate(record[1][key]):
if isinstance(item, bytes) and key != 'objectSid':
value = item.decode('utf-8')
record[1][key][i] = value
or:
for key in record[1]:
for i in range(len(record[1][key])):
if isinstance(record[1][key][i], bytes) and key != 'objectSid':
value = record[1][key][i].decode('utf-8')
record[1][key][i] = value
How would your suggestions work?
from nsscache.
Related Issues (20)
- reformat by removing error E713 for membership test HOT 7
- ShadowExpire == -1 HOT 1
- sshkey map fails to import HOT 4
- Not all LDAP servers provide LastModification Dates
- bsddb3 is deprecated HOT 3
- `uidattr` ignored when writing out groups
- mox3 archived & deprecated upstream, please update tests to not use it HOT 3
- Does not work offline. HOT 6
- Question: Merge groups with the same ids
- Add support for GCS source HOT 1
- Example AuthorizedKeysCommand returns keys for other users if the username is a substring HOT 2
- Please support nested groups HOT 11
- Tagging of versions HOT 3
- nsscache doesn't update group cache from ldap source HOT 7
- ConfigParser.NoSectionError: No section: 'suffix' with nsscache >= 0.36 HOT 2
- configure nsscache with samba4 active directory HOT 31
- is nsscache python3 compatible? HOT 25
- Get integration tests running in CI HOT 37
- Properly define byte vs string types in source and cache api boundaries
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nsscache.