Imported sources.
This commit is contained in:
31
scripts/search.py
Normal file
31
scripts/search.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from ldap3 import Server, Connection, ALL
|
||||
import streamlit as st
|
||||
|
||||
BASE_DN = "dc=koszewscy,dc=waw,dc=pl"
|
||||
LDAP_HOST = "gra-01.koszewscy.waw.pl"
|
||||
LDAP_PORT = 389
|
||||
|
||||
st.set_page_config(page_title="LDAP Search", layout="wide")
|
||||
|
||||
host = st.text_input("Host", LDAP_HOST)
|
||||
port = st.number_input("Port", value=LDAP_PORT, step=1)
|
||||
bind_dn = st.text_input("Bind DN", f"cn=admin,{BASE_DN}")
|
||||
password = st.text_input("Password", type="password")
|
||||
base_dn = st.text_input("Base DN", BASE_DN)
|
||||
search_filter = st.text_input("Filter", "(objectClass=*)")
|
||||
|
||||
if st.button("Search"):
|
||||
server = Server(host, port=port, get_info=ALL)
|
||||
conn = Connection(server, user=bind_dn, password=password, auto_bind=True)
|
||||
ok = conn.search(
|
||||
search_base=base_dn,
|
||||
search_filter=search_filter,
|
||||
attributes=["*"]
|
||||
)
|
||||
if ok:
|
||||
st.write(f"Entries: {len(conn.entries)}")
|
||||
for e in conn.entries:
|
||||
st.code(e.entry_to_ldif())
|
||||
else:
|
||||
st.error(conn.result)
|
||||
conn.unbind()
|
||||
Reference in New Issue
Block a user