Moved script/tool prototypes to a separated directory.

This commit is contained in:
2026-05-04 07:27:10 +02:00
parent a3f3105081
commit 1c9ba9e92c
2 changed files with 0 additions and 0 deletions

31
prototypes/search.py Normal file
View 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()