forked from liamgilbey/ldapr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
77 lines (54 loc) · 2.1 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```
# ldapr
<!-- badges: start -->
[](https://travis-ci.org/liamgilbey/ldapr)
[](https://codecov.io/gh/liamgilbey/ldapr?branch=master)
<!-- badges: end -->
## Overview
ldapr is a system for [LDAP](https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol) authentication in R. It acts as a wrapper around [lidlap](https://www.openldap.org/software/man.cgi?query=ldap) to provide a central authentication mechanism to R products. The primary goal is to provide an LDAP client to shiny applications that require authentication, without having to resort to options such as Shiny Server Pro.
All suggestions are appreciated, so please get in touch.
## Installation
As this package relies on `libldap` this needs to be installed at the system level.
```sh
# Debian systems
apt install libldap-2.4-2
```
For now this package is only available from GitHub.
```{r, eval = FALSE}
# install.packages("devtools")
devtools::install_github("liamgilbey/ldapr")
```
## Usage
The central object in `ldapr` is the R6 class `ldap`. As with all R6 classes, a new `ldap` object is created with the `new` method. For testing purposes, we can attempt to authenticate against the free online LDAP server hosted by [zflexldap](https://www.zflexldapadministrator.com/index.php/blog/82-free-online-ldap).
```{r}
library(ldapr)
```
```{r}
l <- ldap$new(
host = "zflexldap.com",
base_dn = "ou=users,ou=guests,dc=zflexsoftware,dc=com"
)
l
```
Authenticating against the LDAP server is then easy with envoking the `bind` method.
```{r}
l$bind(
user = "guest1",
pw = "guest1password",
"uid"
)
```
Once bound and authenticated with the LDAP server, we can perform search operations to lookup entries in the DN.
```{r}
l$search("(uid=guest2)")
```