Skip to content

Instantly share code, notes, and snippets.

View francescm's full-sized avatar

Francesco Malvezzi francescm

  • Universita' di Modena e Reggio nell'Emilia
  • Italy
View GitHub Profile
@francescm
francescm / ldap_db.ldif
Created July 24, 2013 12:22
A simple ldap backend database
dn: olcDatabase={1}ldap,cn=config
objectClass: olcDatabaseConfig
objectClass: olcLdapConfig
olcDatabase: {1}ldap
olcSuffix: dc=example,dc=org
olcRootDN: cn=ldap-admin
olcAccess: {0}to * by dn.exact=gidNumber=0+uidNumber=0,cn=peercred,cn=external
,cn=auth manage by * break
olcAccess: {1}to * by * read
olcDbStartTLS: start
dn: cn=config
changetype: modify
replace: olcAuthzPolicy
olcAuthzPolicy: to
dn: cn=proxy,ou=agents,dc=example,dc=org
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: proxy
description: principal for proxy ldap
userPassword: {SSHA}LCLFm/lhsZqr4ltuGoyrr/zKGZgJSZ3c
authzTo: {0}dn.regex:^uid=[^,]*,ou=people,dc=example,dc=org$
authzTo: {1}dn.regex:^cn=[^,]*,ou=agents,dc=example,dc=org$
dn: olcDatabase={2}ldap,cn=config
changetype: modify
replace: olcDbIDAssertAuthzFrom
olcDbIDAssertAuthzFrom: "dn:*"
-
replace: olcDbIDAssertBind
olcDbIDAssertBind: mode=self bindmethod=simple binddn="cn=proxy,ou=agents,dc=example,dc=org" credentials=KHg7VvVD
Aug 1 10:36:59 proxy slapd[23946]: conn=1057 fd=19 ACCEPT from PATH=/var/run/slapd/ldapi (PATH=/var/run/slapd/ldapi)
Aug 1 10:36:59 proxy slapd[23946]: conn=1057 op=0 SRCH base="" scope=0 deref=0 filter="(objectClass=*)"
Aug 1 10:36:59 proxy slapd[23946]: conn=1057 op=0 SRCH attr=supportedSASLMechanisms
Aug 1 10:36:59 proxy slapd[23946]: conn=1057 op=0 ENTRY dn=""
Aug 1 10:36:59 proxy slapd[23946]: conn=1057 op=0 SEARCH RESULT tag=101 err=0 nentries=1 text=
Aug 1 10:36:59 proxy slapd[23946]: conn=1057 op=1 BIND dn="" method=163
Aug 1 10:36:59 proxy slapd[23946]: conn=1057 op=1 RESULT tag=97 err=14 text=SASL(0): successful result: security flags do not match required
Aug 1 10:36:59 proxy slapd[23946]: conn=1057 op=2 BIND dn="" method=163
Aug 1 10:36:59 proxy slapd[23946]: conn=1057 op=2 RESULT tag=97 err=14 text=SASL(0): successful result: security flags do not match required
Aug 1 10:36:59 proxy slapd[23946]: conn=1057 op=3 BIND dn="" method=163
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 fd=22 ACCEPT from IP=10.0.0.1:43682 (IP=0.0.0.0:389)
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 op=0 EXT oid=1.3.6.1.4.1.1466.20037
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 op=0 STARTTLS
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 op=0 RESULT oid= err=0 text=
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 fd=22 TLS established tls_ssf=128 ssf=128
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 op=1 BIND dn="cn=proxy,ou=agents,dc=example,dc=org" method=128
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 op=1 BIND dn="cn=proxy,ou=agents,dc=example,dc=org" mech=SIMPLE ssf=0
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 op=1 RESULT tag=97 err=0 text=
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 op=2 PROXYAUTHZ dn="uid=a_user,ou=people,dc=example,dc=org"
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 op=2 SRCH base="dc=example,dc=org" scope=2 deref=0 filter="(uid=a_user)"
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 fd=22 ACCEPT from IP=10.0.0.1:43682 (IP=0.0.0.0:389)
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 op=0 EXT oid=1.3.6.1.4.1.1466.20037
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 op=0 STARTTLS
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 op=0 RESULT oid= err=0 text=
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 fd=22 TLS established tls_ssf=128 ssf=128
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 op=1 BIND dn="cn=proxy,ou=agents,dc=example,dc=org" method=128
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 op=1 BIND dn="cn=proxy,ou=agents,dc=example,dc=org" mech=SIMPLE ssf=0
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 op=1 RESULT tag=97 err=0 text=
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 op=2 PROXYAUTHZ dn="uid=a_user,ou=people,dc=example,dc=org"
Aug 1 10:36:44 openldap slapd[19002]: conn=1662 op=2 SRCH base="dc=example,dc=org" scope=2 deref=0 filter="(uid=a_user)"
@francescm
francescm / susi909.clj
Created August 25, 2013 09:30
Solver for the Quesito con la Susi n. 909.
(def not-italian-chars #{\J \K \X \Y \W})
(def the-chars (cycle (clojure.set/difference (set (range (int \A) (+ (int \Z) 1))) (map int not-italian-chars))))
(def the-chars (cycle (filter #(not ((set (map int not-italian-chars)) %)) (range (int \A) (+ (int \Z) 1)))))
(def char-with-index (reduce #(assoc %1 %2 (count %1)) {} (take 21 the-chars)))
(defn alpha [offset] (take 21 (drop (char-with-index (int offset)) the-chars)))
(map #(apply str (vec (map char %&))) (alpha \S) (alpha \P) (alpha \A) (alpha \D) (alpha \E))
@francescm
francescm / ldif-writer.clj
Created September 27, 2013 06:12
Write to file a ldif created by hand (by example: queries to relational databases). This is a step needed to bootstrap the OpenLDAP.
(import '(org.ldaptive.io LdifWriter))
(import '(java.io StringWriter))
(import '(org.ldaptive LdapEntry LdapAttribute SortBehavior))
(def attr1 (LdapAttribute/createLdapAttribute SortBehavior/UNORDERED
"mail"
["francesco.mlvz@gmail.com" "francesco.malvezzi@unimore.it"]
)
)
@francescm
francescm / strategy.rb
Created October 19, 2013 16:07
Rock paper scissor strategy class
class Strategy
include Comparable
attr :strategy
def initialize(strategy)
# @@order should read: r eats s eats p eats r
@@order ="rspr"
raise NoSuchStrategyError, "Strategy must be one of R,P,S" unless %w{R P S r p s}.include? strategy
@strategy = strategy.downcase
end