Query LDAP and AD with SQL

Overview

SQLDAP

Ever wanted to query AD or LDAP with SQL like queries ?

I'm going to answer this question myself: yes ! Why ? Because I never could remember all the ldapsearch arguments and filters, etc.

But after building this tool I am now a master of ldapsearch :)

Supported queries:

  • simple select queries: SELECT * FROM "$tablename" WHERE var=val;
  • show databases; show tables;

Work in Progress:

  • update queries: Don't use this in a production environment !!!

Example queries:

@group should be defined in sqldap.ini (see sqldap.ini.example)

Select from default (first) configured server:

[user@awesome ~]$ sqldap 'SELECT memberuid FROM @group WHERE cn=groupname'

Select from a different configured Active Directory server named examplead

[user@awesome ~]$ sqldap 'SELECT gid FROM @group ' examplead

Don't use > and <

> and < are not supported, work your way around this problem by using: >= and <=

This is a valid query:

[user@awesome ~]$ sqldap 'SELECT uid,cn,passwordretrycount,ou FROM @people WHERE passwordretrycount>=3'

This is an invalid query:

[user@awesome ~]$ sqldap 'SELECT uid,cn,passwordretrycount,ou FROM @people WHERE passwordretrycount>2'`

You can also run queries that are defined in the sqldap.ini config file:

[user@awesome ~]$ sqldap @passwordretrycount

When you pass a filename as an argument, then sqldap parses the file and executes the queries that are defined this file

[user@awesome ~]$ sqldap queries.sql

Using config file /home/user/sqldap/sqldap.ini
Using server: exampleldap (ldap://ldap.example.com:389)

+-------+-------------+--------------------+----------+
| uid   | cn          | passwordretrycount | ou       |
+-------+-------------+--------------------+----------+
| user1 | Username1   | 3                  | group1   |
+-------+-------------+--------------------+----------+
| user2 | Username2   | 3                  | group2   |
+-------+-------------+--------------------+----------+
| user3 | Username3   | 3                  | group3   |
+-------+-------------+--------------------+----------+

[user@awesome ~]$

Compiling from source

First you'll have to install Rust on your system:

[user@awesome ~]$ curl https://sh.rustup.rs -sSf | sh

Now run the following command in the root of the project:

[user@awesome ~]$ cargo build --release

The sqldap binary can be found in the target/release/ folder.

You might also like...
A Toy Query Engine & SQL interface
A Toy Query Engine & SQL interface

Naive Query Engine (Toy for Learning) 😄 This is a Query Engine which support SQL interface. And it is only a Toy for learn query engine only. You can

Query system statistics with SQL.

pg_stat_sysinfo Collects system statistics. ---- CREATE EXTENSION pg_stat_sysinfo; CREATE EXTENSION ---- SELECT * FROM pg_stat_sysinfo_collect();

rust_arango enables you to connect with ArangoDB server, access to database, execute AQL query, manage ArangoDB in an easy and intuitive way, both async and plain synchronous code with any HTTP ecosystem you love.

rust_arango enables you to connect with ArangoDB server, access to database, execute AQL query, manage ArangoDB in an easy and intuitive way, both async and plain synchronous code with any HTTP ecosystem you love.

FeOphant - A SQL database server written in Rust and inspired by PostreSQL.

A PostgreSQL inspired SQL database written in Rust.

Distributed, version controlled, SQL database with cryptographically verifiable storage, queries and results. Think git for postgres.

SDB - SignatureDB Distributed, version controlled, SQL database with cryptographically verifiable storage, queries and results. Think git for postgres

PRQL is a modern language for transforming data — a simpler and more powerful SQL

PRQL Pipelined Relational Query Language, pronounced "Prequel". PRQL is a modern language for transforming data — a simpler and more powerful SQL. Lik

ReadySet is a lightweight SQL caching engine written in Rust that helps developers enhance the performance and scalability of existing applications.
ReadySet is a lightweight SQL caching engine written in Rust that helps developers enhance the performance and scalability of existing applications.

ReadySet is a SQL caching engine designed to help developers enhance the performance and scalability of their existing database-backed applications. W

SQL database to read and write
SQL database to read and write "discord"

GlueSQL Discord Storage After discussing how CI testing will be managed, we plan to move it upstream. Precautions for use discord ToS https://discord.

Execute SQL now and get the results later.

pg_later Execute SQL now and get the results later. A postgres extension to execute queries asynchronously. Installation Add pg_later to shared_preloa

Owner
null
Gh-sql - Query GitHub Projects (beta) with SQL

gh-sql: Query GitHub Projects (beta) with SQL Installation gh extension install KOBA789/gh-sql Features SELECT items DELETE items UPDATE item fields

Hidekazu Kobayashi 108 Dec 7, 2022
LDAP support for the r2d2 connection pool

r2d2-ldap LDAP support for the r2d2 connection pool Install Add this to your Cargo.toml: [dependencies] r2d2-ldap = "0.1.1" Basic Usage use std::threa

Aitor Ruano 2 Nov 7, 2020
LDAP client library

LDAP client library A pure-Rust LDAP client library using the Tokio stack. Compatibility with Tokio versions Tokio 1.0 is the long-term stable version

null 166 Jan 4, 2023
ReefDB is a minimalistic, in-memory and on-disk database management system written in Rust, implementing basic SQL query capabilities and full-text search.

ReefDB ReefDB is a minimalistic, in-memory and on-disk database management system written in Rust, implementing basic SQL query capabilities and full-

Sacha Arbonel 75 Jun 12, 2023
🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, SQLite, and MSSQL.

SQLx ?? The Rust SQL Toolkit Install | Usage | Docs Built with ❤️ by The LaunchBadge team SQLx is an async, pure Rust† SQL crate featuring compile-tim

launchbadge 7.6k Dec 31, 2022
Rust library to parse, deparse and normalize SQL queries using the PostgreSQL query parser

This Rust library uses the actual PostgreSQL server source to parse SQL queries and return the internal PostgreSQL parse tree.

pganalyze 37 Dec 18, 2022
SQL validator tool for BigQuery standard SQL.

bqvalid What bqvalid does bqvalid is the SQL validator tool for BigQuery standard SQL. bqvalid fails with error message if there's the expression that

null 10 Dec 25, 2022
An object-relational in-memory cache, supports queries with an SQL-like query language.

qlcache An object-relational in-memory cache, supports queries with an SQL-like query language. Warning This is a rather low-level library, and only p

null 3 Nov 14, 2021
Fully typed SQL query builder for Rust [deprecated]

What is Deuterium? Deuterium is a fancy SQL builder for Rust. It's designed to provide a DSL to easily build SQL queries in safe and typed way. Like R

Stanislav Panferov 169 Nov 20, 2022
Type-safe SQL query wrappers

fnsql   The fnsql crate provides simple type-safe optional wrappers around SQL queries. Instead of calling type-less .query() and .execute(), you call

Dan Aloni 9 Apr 29, 2022