versuche schon seit zwei wochen eine übersicht eines ldap dirs in ein webformular/tabelle zu bringen. muss dazu sagen, ich habe noch keine einzige zeile python geschrieben bevor ich zu dieser angelegenheit verdonnert wurde, also total planlos. dementsprechend schnell ist die sache auch ziemlich eklig geworden.
also das dict sieht so aus.
Code: Alles auswählen
>>> conn.entries
[DN: cn=defaults,ou=SUDOers,ou=apps,dc=mydomain,dc=at - STATUS: Read - READ TIME: 2018-05-14T10:59:12.767401
cn: defaults
, DN: cn=XDB_STAFF_2,ou=SUDOers,ou=apps,dc=mydomain,dc=at - STATUS: Read - READ TIME: 2018-05-14T10:59:12.768807
cn: XDB_STAFF_2
sudoCommand: /usr/bin/su -
/usr/bin/su - -c *
sudoHost: ALL
sudoUser: blue
neydwa
schama
wimm
oberwa
flecal
dattju
etzean
pomaan
, DN: cn=XDB_EXTERN,ou=SUDOers,ou=apps,dc=mydomain,dc=at - STATUS: Read - READ TIME: 2018-05-14T10:59:12.769131
cn: XDB_EXTERN
sudoCommand: /usr/bin/su - ora*
sudoHost: ALL
sudoUser: plesma
wilsch
reifwa
renndo
poelma
...
Code: Alles auswählen
{% extends "base.html" %}
{% block content %}
<table id="sudo_tables" class="display">
<thead>
<tr>
<th>Sudo Group</th>
<th>Sudo User</th>
<th>Sudo Command</th>
<th>Sudo Host</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ cn }}</td>
<td>{{ sudoUser }}</td>
<td>{{ sudoCommand }}</td>
<td>{{ sudoHost }}</td>
</tr>
</tbody>
</table>
{% endblock %}
Code: Alles auswählen
@app.route('/overview', methods = ['GET', 'POST'])
def overview():
form = OverviewForm()
searchParameters = { 'search_base':
'ou=SUDOers,ou=apps,dc=mydomain,dc=at',
'search_filter': '(objectclass=SudoRole)',
'attributes': ['cn', 'sudoUser', 'sudoCommand',
'sudoHost'] }
server = Server('lpgaixmgmtlx01.test.mydomain', get_info=ALL)
conn = Connection(server, 'cn=roots,dc=mydomain,dc=at','blabla', auto_bind=True)
conn.search(**searchParameters)
for key, val in conn.entries.iteritems():
cn = map(str,conn.entries.cn)
sudoUser = map(str,conn.entries.sudoUser)
sudoCommand = map(str,conn.entries.sudoCommand)
sudoHost = map(str,conn.entries.sudoHost)
return render_template('overview.html', cn = cn, sudoUser = sudoUser,
sudoCommand = sudoCommand, sudoHost = sudoHost, form
= form)
vielleicht hat ja jemand ne zündende idee...
lg
chris