<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>ldap &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/ldap/</link>
	<description>Feed of posts on WordPress.com tagged "ldap"</description>
	<pubDate>Sat, 28 Nov 2009 11:22:34 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Lift LDAP]]></title>
<link>http://jgoday.wordpress.com/2009/11/27/lift-ldap/</link>
<pubDate>Fri, 27 Nov 2009 13:12:44 +0000</pubDate>
<dc:creator>jgoday</dc:creator>
<guid>http://jgoday.wordpress.com/2009/11/27/lift-ldap/</guid>
<description><![CDATA[One of the requisites to start using Lift at my work, was to use LDAP authentification. So i wrote a]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>One of the requisites to start using <a href="http://liftweb.net/">Lift</a> at my work, was to use LDAP authentification.<br />
So i wrote a little module <a href="http://github.com/jgoday/lift-ldap">lift-ldap</a> for that and a <a href="http://github.com/jgoday/sample_lift_ldap">sample app</a>, it was damn simple !</p>
<p>To use the module, </p>
<ul>
<li><b>1. lift-ldap requirements in maven pom.xml</b>
<div style="border:1px dotted #909090;background-color:#f7f7f7;overflow:auto;padding:4px;">
<pre>
<code>
&#60;dependency&#62;
    &#60;groupId&#62;net.liftweb&#60;/groupId&#62;
    &#60;artifactId&#62;lift-ldap&#60;/artifactId&#62;
    &#60;version&#62;1.0.0&#60;/version&#62;
&#60;/dependency&#62;
</code></pre>
</div>
</li>
<li>
        <b>2. Create the user object in src/scala/com/sample/model/User.scala</b></p>
<div style="border:1px dotted #909090;background-color:#f7f7f7;overflow:auto;padding:4px;">
<pre>
<code>
package com.sample.model

import scala.util.matching.{Regex}
import scala.xml.{NodeSeq}

// lift ldap
import net.liftweb.ldap.{LDAPProtoUser, MetaLDAPProtoUser, LDAPVendor, SimpleLDAPVendor}

import net.liftweb.common.{Box, Full}
import net.liftweb.http.{S, SessionVar}
import net.liftweb.mapper.{KeyedMetaMapper}

object roles extends SessionVar[List[String]](List())

class User extends LDAPProtoUser[User] {
    def getSingleton = User

    def getRoles: List[String] = {
        return roles.get
    }
}

object User extends User with MetaLDAPProtoUser[User] {

    override def screenWrap = Full(

    )

    override def dbTableName = "tmp_users"

    override def login : NodeSeq = {
        val groupNameRx = new Regex(".*cn=(.*),ou=.*")

        def getGroupNameFromDn(dn: String): String = {
            val groupNameRx(groupName) = dn
            return groupName
        }

        def setRoles(userDn: String, ldapVendor: LDAPVendor): AnyRef = {
            // buscamos o grupo do usuario
            val filter = "(&#38;(objectclass=groupofnames)(member=" + userDn + "))"

            val groups = ldapVendor.search(filter)
            groups.foreach(g =&#62; {
                roles.set(roles.get + getGroupNameFromDn(g))
            })
        }

        login(setRoles _)
    }
}

</code></pre>
</div>
<p>    The User object has to provide a setRoles function to the LDAPVendor (when do login),<br />
    so we can customize the way in which we retrieve the credentials from LDAP (from a group of names or a custom object)
    </li>
<li>
        <b>3. Initialize the LDAP configuration in Boot.scala (src/main/scala/bootstrap/liftweb/Boot.scala)</b></p>
<div style="border:1px dotted #909090;background-color:#f7f7f7;overflow:auto;padding:4px;">
<pre>
<code>
We can pass a properties file to the SimpleLDAPVendor
SimpleLDAPVendor.parameters = () =&#62;
            SimpleLDAPVendor.parametersFromStream(
                this.getClass().getClassLoader().getResourceAsStream("ldap.properties"))

or just manually :
SimpleLDAPVendor.parameters = () =&#62; Map("ldap.url"  -&#62; "ldap://localhost",
                                        "ldap.base" -&#62; "dc=company,dc=com",
                                        "ldap.userName" -&#62; "...",
                                        "ldap.password" -&#62; "...")

</code></pre>
</div>
</li>
<li>
        <b>4. A LoginUtils class (src/main/scala/com/sample/lib/LoginUtil.scala)</b></p>
<p>        To determine when the user is logged or have some credentials
    </li>
<li>
        <b>5. Create the security rules in Boot</b> </p>
<div style="border:1px dotted #909090;background-color:#f7f7f7;overflow:auto;padding:4px;">
<pre>
<code>

    LiftRules.dispatch.prepend(NamedPF("Login Validation") {
        case Req("group_required" :: page, extension, _) if !LoginUtil.hasAuthority_?("sample_group") =&#62;
                LoginUtil.redirectIfLogged("/login/group_not_allowed")
        case Req("login_required" :: page , extension, _) if (!LoginUtil.isLogged) =&#62;
                () =&#62; Full(RedirectResponse("/user_mgt/login"))
    })
</code></pre>
</div>
</li>
</ul>
<p><a href="http://jgoday.wordpress.com/files/2009/11/snapshot3.png"><img src="http://jgoday.wordpress.com/files/2009/11/snapshot3.png" alt="" title="snapshot3" width="570" height="369" class="aligncenter size-full wp-image-119" /></a></p>
<p>And that&#8217;s it <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Liferay Integration – CAS w/ LDAP]]></title>
<link>http://pojoe.wordpress.com/2009/11/27/liferay-integration-%e2%80%93-cas-w-ldap/</link>
<pubDate>Fri, 27 Nov 2009 05:59:43 +0000</pubDate>
<dc:creator>Joseph Shum</dc:creator>
<guid>http://pojoe.wordpress.com/2009/11/27/liferay-integration-%e2%80%93-cas-w-ldap/</guid>
<description><![CDATA[I recently had to walk a client through installing Liferay integrated with SSO and LDAP. Here’s a si]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I recently had to walk a client through installing Liferay integrated with SSO and LDAP. Here’s a simple summary of how I got it setup.</p>
<p>I set up the following components:</p>
<p>Application Server:  Liferay 5.2.5 EE / Tomcat 6.0.18 (www.pojoe.ca)</p>
<p>CAS Server:              JA-SIG CAS Server 3.3.3 Final (sso.pojoe.ca)</p>
<p>LDAP Server:          Apache Directory Server 1.5.5 (ldap.pojoe.ca)</p>
<p>Getting Liferay setup is a topic for an entirely different post so here I’m going to assume you have an out of the box Liferay running on your application server. Go over to <a href="http://www.liferay.com/web/guest/downloads/portal">http://www.liferay.com/web/guest/downloads/portal</a> and get yourself a portal if you haven’t already.</p>
<p>The first thing we’re going to do is install JA-SIG CAS Server 3.3.3 Final.</p>
<p>I drop cas-server-3.3.3-release\cas-server-3.3.3\modules\cas-server-webapp-3.3.3.war into Tomcat rename the war to <strong>cas-web</strong> and let it deploy.</p>
<p>You’ll need to configure Tomcat to allow for HTTPS connections.</p>
<p>I’ve detailed this process<a href="../2009/11/27/configuring-https-on-tomcat-6-0-18/"></a> <a href="http://pojoe.wordpress.com/2009/11/26/configuring-https-on-tomcat-6-0-18/" target="_self">here</a> in another post.</p>
<p>That is pretty much all you have to do to get a basic SSO server up and running.</p>
<p>Next you’ll want to configure Liferay to use the SSO server. This is of course, like everything else in Liferay, simple. =)</p>
<p>The CAS client jar should already be bundled but you can grab it here as well.</p>
<p>Download the CAS client from <a href="http://www.ja-sig.org/downloads/cas-clients/ cas-client-java-2.1.1" target="_blank">here</a>.</p>
<p>In portal-ext.properties add the following lines.</p>
<p>##<br />
## Company<br />
##</p>
<p>#<br />
# The portal can authenticate users based on their email address, screen<br />
# name, or user id.<br />
#<br />
#company.security.auth.type=emailAddress<br />
company.security.auth.type=screenName<br />
#company.security.auth.type=userId</p>
<p>##<br />
## CAS<br />
##</p>
<p>#<br />
# Set this to true to enable CAS single sign on. NTLM will work only if<br />
# LDAP authentication is also enabled and the authentication is made by<br />
# screen name. If set to true, then the property &#8220;auto.login.hooks&#8221; must<br />
# contain a reference to the class<br />
# com.liferay.portal.security.auth.CASAutoLogin and the filter<br />
# com.liferay.portal.servlet.filters.sso.cas.CASFilter must be referenced<br />
# in web.xml.<br />
#</p>
<p>cas.auth.enabled=true</p>
<p>#<br />
# A user may be authenticated from CAS and not yet exist in the portal. Set<br />
# this to true to automatically import users from LDAP if they do not exist<br />
# in the portal.<br />
#</p>
<p>cas.import.from.ldap=false</p>
<p>#<br />
# Set the default values for the required CAS URLs. Set either<br />
# &#8220;cas.server.name&#8221; or &#8220;cas.service.url&#8221;. Setting &#8220;cas.server.name&#8221; allows<br />
# deep linking. See LEP-4423.<br />
#</p>
<p>cas.login.url=https://sso.pojoe.ca:8443/cas-web/login<br />
cas.logout.url=https://sso.pojoe.ca:8443/cas-web/logout<br />
cas.server.name=www.pojoe.ca:8080<br />
cas.service.url=<br />
#cas.service.url=http://localhost:8080/c/portal/login<br />
cas.validate.url=https://sso.pojoe.ca:8443/cas-web/proxyValidate</p>
<p>Startup Liferay and head for the homepage. Once you are there you should go to the “Sign In” and this should direct you to the CAS SSO login page.</p>
<p>Login with test/test and you should land on your Liferay homepage as the authenticated omni user. Create a new user with the screen name “admin” and with the password “secret”. We’ll be using this default user later to test the LDAP integration.</p>
<p>The next thing we’ll do now is setup an LDAP server. We’ll use ApacheDS 1.5.5. Downloaded from<a href="http://directory.apache.org/apacheds/1.5/downloads.html" target="_blank"> here</a>.</p>
<p>After downloading simply run the installer with all default options.</p>
<p>ApacheDS should now be running and listening on port 10389.</p>
<p>Stop the tomcat server and add cas-server-support-ldap-3.3.3.jar to cas-web/WEB-INF/lib if it isn’t there already.</p>
<p>Edit cas-web\WEB-INF\deployerConfigContext.xml as follows:</p>
<p>1. Add the following bean LDAP authentication:</p>
<p>&#60;bean id=&#8221;contextSource&#8221;&#62;<br />
&#60;property value=&#8221;true&#8221;/&#62;<br />
&#60;property&#62;<br />
&#60;list&#62;<br />
&#60;value&#62;ldap://ldap.pojoe.ca:10389&#60;/value&#62;<br />
&#60;/list&#62;<br />
&#60;/property&#62;<br />
&#60;property value=&#8221;uid=admin,ou=system&#8221;/&#62;<br />
&#60;property value=&#8221;secret&#8221;/&#62;<br />
&#60;property&#62;<br />
&#60;map&#62;<br />
&#60;entry key=&#8221;java.naming.security.authentication&#8221; value=&#8221;simple&#8221; /&#62;<br />
&#60;/map&#62;<br />
&#60;/property&#62;<br />
&#60;/bean&#62;</p>
<p>2. Remove the demo authentication handler, org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler, from the authenticationHandlers property of the org.jasig.cas.authentication.AuthenticationManagerImpl bean.</p>
<p>3. Add the LDAP fast bind authentication handler:</p>
<p>&#60;bean &#62;<br />
&#60;property value=&#8221;uid=%u,ou=system&#8221; /&#62;<br />
&#60;property ref=&#8221;contextSource&#8221; /&#62;<br />
&#60;/bean&#62;</p>
<p>Start tomcat</p>
<p>Open a browser to the URL http://www.pojoe.ca:8080 and authenticate with the following credentials, admin/secret.</p>
<p>The user has signed on over SSO and authenticated with your LDAP server.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Obtener BaseDN de Active Directory]]></title>
<link>http://toniogago.wordpress.com/2009/11/24/obtener-basedn-de-active-directory/</link>
<pubDate>Tue, 24 Nov 2009 13:05:25 +0000</pubDate>
<dc:creator>toniogago</dc:creator>
<guid>http://toniogago.wordpress.com/2009/11/24/obtener-basedn-de-active-directory/</guid>
<description><![CDATA[Para implementar la seguridad con LDAP en algunas aplicaciones es necesario saber la cadena BASE DN ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Para implementar la seguridad con <strong>LDAP</strong> en algunas aplicaciones es necesario saber la cadena <strong>BASE DN</strong> para conectarse al servidor que tenga <strong>Active Directory</strong>. La cadena tiene que hacer referencia a la unidad organizativa <strong>Users</strong>.</p>
<p>Aquí os explico cómo conseguir esa cadena.</p>
<p><!--more--></p>
<p><strong>La utilidad ldp.exe<br />
</strong>El CD1 de Windows Server 2003 contiene utilidades entre las que está ldp.exe. Extraer dicha utilidad que está en el archivo SUPPORT.CAB del directorio \SUPPORT\TOOLS</p>
<p>Ejecutarlo y en el menú <em>connection</em> elegir <em>connect</em>.</p>
<p><img class="alignnone size-full wp-image-109" title="ldap01" src="http://toniogago.wordpress.com/files/2009/11/ldap01.png" alt="Conectar a servidor LDAP" width="273" height="143" /></p>
<p>Introducir el nombre del servidor que tiene el Active Directory. A continuación, en el menú <em>connection</em> elegir la opción <em>bind</em>.</p>
<p><img class="alignnone size-full wp-image-110" title="ldap02" src="http://toniogago.wordpress.com/files/2009/11/ldap02.png" alt="Connection - Bind" width="287" height="164" /></p>
<p>Introducir un usuario cualquiera con su password correspondiente y el dominio. Pulsar el botón OK.</p>
<p>Una vez conectado, en el menú <em>view</em> elegir la opción <em>tree</em>.</p>
<p><img class="alignnone size-full wp-image-111" title="ldap03" src="http://toniogago.wordpress.com/files/2009/11/ldap03.png" alt="Ver árbol de Active Directory" width="437" height="121" /></p>
<p>Desplegar el combo y elegir el primer elemento. Suele ser el nombre del <strong>dominio</strong>. Pulsar el botón OK.</p>
<p><img class="alignnone size-full wp-image-112" title="ldap04" src="http://toniogago.wordpress.com/files/2009/11/ldap04.png" alt="Cadena Base DN Users" width="368" height="383" /></p>
<p>Buscais <strong>Users</strong> dentro de la lista de cadenas y será el <strong>BASE DN</strong> necesario para la implementación de la seguridad con la aplicación.</p>
<p>un saludo.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Scala and ldap]]></title>
<link>http://jgoday.wordpress.com/2009/11/16/scala-and-ldap/</link>
<pubDate>Mon, 16 Nov 2009 21:18:16 +0000</pubDate>
<dc:creator>jgoday</dc:creator>
<guid>http://jgoday.wordpress.com/2009/11/16/scala-and-ldap/</guid>
<description><![CDATA[Playing around with Scala, a very nice jvm language!, found Lift (web framework), looks simple and f]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Playing around with <a href="http://www.scala-lang.org/">Scala</a>, a very nice jvm language!,<br />
found <a href="http://liftweb.net/">Lift (web framework)</a>,<br />
looks simple and funny !</p>
<p>I was looking for ldap authentication with lift,<br />
i wasn&#8217;t able to find nothing <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> . </p>
<p>So i started to play with it,<br />
Here, I install an openldap server and some simple scala code to play with it.</p>
<ul>
<li>
<strong>Install openldap and some sample data (using arch linux)</strong></p>
<div style="border:1px dotted #909090;background-color:#f7f7f7;overflow:auto;padding:4px;">
<pre>
<code>
1- sudo pacman -S openldap
2- slappasswd -h {MD5} -s password (generates ldap password to use it later in config and user ldif file)
   {MD5}X03MO1qnZdYdgyfeuILPmQ==
</code></pre>
</div>
</li>
<li>
        <strong>Generate the ldap structure</strong> in initial_structure.ldif file</p>
<div style="border:1px dotted #909090;background-color:#f7f7f7;overflow:auto;padding:4px;">
<pre>
<code>
dn: dc=company,dc=com
dc: company
description: LDAP Main object
objectClass: organization
objectClass: dcObject
o: company.com

dn: ou=Users,dc=company,dc=com
ou: Users
objectClass: organizationalUnit

dn: ou=Groups,dc=company,dc=com
ou: Groups
objectClass: top
objectClass: organizationalUnit

dn: cn=main_group,ou=Groups,dc=company,dc=com
gidNumber: 2000
objectClass: posixGroup
objectClass: top
cn: main_group

dn: cn=secondary_group,ou=Groups,dc=company,dc=com
gidNumber: 2001
objectClass: posixGroup
objectClass: top
cn: secondary_group
</code></pre>
</div>
</li>
<li>
        <strong>Configure ldap server</strong> in /etc/openldap/slapd.conf</p>
<div style="border:1px dotted #909090;background-color:#f7f7f7;overflow:auto;padding:4px;">
<pre>
<code>
include         /etc/openldap/schema/core.schema
include         /etc/openldap/schema/cosine.schema
include         /etc/openldap/schema/courier.schema
include         /etc/openldap/schema/inetorgperson.schema
include         /etc/openldap/schema/nis.schema

allow bind_v2
password-hash {md5}

pidfile   /var/run/slapd.pid
argsfile  /var/run/slapd.args

database        bdb
suffix          "dc=company,dc=com"
rootdn          "cn=admin,dc=company,dc=com"
rootpw          {MD5}X03MO1qnZdYdgyfeuILPmQ==

directory       /var/lib/openldap/openldap-data
index   objectClass     eq
index   uid     eq
</code></pre>
</div>
</li>
<li>
        <strong>Populate initial ldap structure</strong></p>
<div style="border:1px dotted #909090;background-color:#f7f7f7;overflow:auto;padding:4px;">
<pre>
<code>
sudo /usr/sbin/slapadd -l initial_structure.ldif
</code></pre>
</div>
</li>
<li>
        <strong>Populate user and group data</strong>, for example in file users.ldif</p>
<div style="border:1px dotted #909090;background-color:#f7f7f7;overflow:auto;padding:4px;">
<pre>
<code>
dn: uid=sample_user_1,ou=Users,dc=company,dc=com
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: shadowAccount
uid: sample_user_1
cn: Test User
sn: User
givenName: Test
userPassword: {MD5}X03MO1qnZdYdgyfeuILPmQ==
loginShell: /bin/bash
uidNumber: 10000
gidNumber: 2000
homeDirectory: /home/users/test/
</code></pre>
</div>
</li>
<li>
        <strong>Starts ldap server and add users.ldif</strong></p>
<div style="border:1px dotted #909090;background-color:#f7f7f7;overflow:auto;padding:4px;">
<pre>
<code>
sudo /etc/rc.d/sldap start
ldapadd -x -D "cn=admin,dc=company,dc=com" -f users.ldif -W
</code></pre>
</div>
</li>
<li><strong>Test ldap server</strong> searching for sample_user_1 user
<div style="border:1px dotted #909090;background-color:#f7f7f7;overflow:auto;padding:4px;">
<pre>
<code>
ldapsearch -x -D "cn=admin,dc=company,dc=com" -b "dc=company,dc=com" "(&#38;(uid=sample_user_1))" -W
</code></pre>
</div>
</li>
</ul>
<p></p>
<hr />
</p>
<ul>
<li><strong>And now scala code <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </strong>
<div style="border:1px dotted #909090;background-color:#f7f7f7;overflow:auto;padding:4px;">
<pre>
<code>
import java.io.FileInputStream
import java.util.{Hashtable, Properties}

import javax.naming.Context
import javax.naming.directory.{BasicAttributes, SearchControls}
import javax.naming.ldap.{LdapName, InitialLdapContext}

import scala.collection.jcl.{MapWrapper}
import scala.util.logging.{Logged, ConsoleLogger}

implicit def convert(javaMap: Hashtable[String, String]) = {
    Map.empty ++ new MapWrapper[String, String]() {
        def underlying = javaMap
    }
} 

type StringMap = Map[String, String]

val DEFAULT_URL = "localhost"
val DEFAULT_BASE_DN = ""
val DEFAULT_USER = ""
val DEFAULT_PASSWORD = ""

object SimpleLDAPSearch {
    lazy val ldap: LDAPSearch = {
        if (properties() == null) {
            val p = new Properties()
            p.load(new FileInputStream(propertiesFile()))

            // automatically calls convert(javaMap: Hashtable[String, String])
            properties = () =&#62; p.asInstanceOf[StringMap]
        }

        new LDAPSearch(properties()) with ConsoleLogger
    }

    var properties: () =&#62; StringMap = () =&#62; null
    var propertiesFile: () =&#62; String = {
        () =&#62; "DEFAULT_PROPERTIES_FILE.properties"
    }
}

class LDAPSearch(parameters: StringMap) extends Logged {
    lazy val initialContext = getInitialContext(parameters)

    def search(filter: String) : List[String] = {
        log("--&#62; LDAPSearch.search: Searching for '%s'".format(filter))

        var list = List[String]()

        val ctx = initialContext

        if (!ctx.isEmpty) {
            val result = ctx.get.search(parameters.getOrElse("ldap.base", DEFAULT_BASE_DN),
                                        filter,
                                        getSearchControls())

            while(result.hasMore()) {
                var r = result.next()
                list = list ::: List(r.getName)
            }
        }

        return list
    }

    def bindUser(dn: String, password: String) : Boolean = {
        log("--&#62; LDAPSearch.bindUser: Try to bind user '%s'".format(dn))

        var result = false

        try {
            var env = new Hashtable[String, String]()
            env.put(Context.PROVIDER_URL, parameters.getOrElse("ldap.url", DEFAULT_URL))
            env.put(Context.SECURITY_AUTHENTICATION, "simple")
            env.put(Context.SECURITY_PRINCIPAL, dn + "," + parameters.get("ldap.base"))
            env.put(Context.SECURITY_CREDENTIALS, password)
            env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory")

            var ctx = Some(new InitialLdapContext(env, null))

            result = !ctx.isEmpty
            ctx.get.close
        }
        catch {
            case e: Exception =&#62; println(e)
        }

        log("--&#62; LDAPSearch.bindUser: Bind successfull ? %s".format(result))

        return result
    }

    private def getInitialContext(props: StringMap) : Option[InitialLdapContext] = {

        log("--&#62; LDAPSearch.getInitialContext: Get initial context from '%s'".format(props.get("ldap.url")))

        var env = new Hashtable[String, String]()
        env.put(Context.PROVIDER_URL, props.getOrElse("ldap.url", DEFAULT_URL))
        env.put(Context.SECURITY_AUTHENTICATION, "simple")
        env.put(Context.SECURITY_PRINCIPAL, props.getOrElse("ldap.userName", DEFAULT_USER))
        env.put(Context.SECURITY_CREDENTIALS, props.getOrElse("ldap.password", DEFAULT_PASSWORD))
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory")

        return Some(new InitialLdapContext(env, null))
    }

    private def getSearchControls() : SearchControls = {
        val searchAttributes = new Array[String](1)
        searchAttributes(0) = "cn"

        val constraints = new SearchControls()
        constraints.setSearchScope(SearchControls.SUBTREE_SCOPE)
        constraints.setReturningAttributes(searchAttributes)
        return constraints
    }
}

// SimpleLDAPSearch.propertiesFile = () =&#62; "ldap.properties"

SimpleLDAPSearch.properties = () =&#62; {
    Map("ldap.url" -&#62; "ldap://localhost",
        "ldap.userName" -&#62; "cn=admin,dc=company,dc=com",
        "ldap.password" -&#62; "password",
        "ldap.base" -&#62; "dc=company,dc=com")
}

val list1 = SimpleLDAPSearch.ldap.search("(uid=sample_user_1)")
println(SimpleLDAPSearch.ldap.bindUser(list1(0), "password"))
</code></pre>
</div>
<p>The code is not exactly perfect,<br />
but shows how simple can scala be.
    </li>
</ul>
<h3>Here&#8217;s my favourites lines of code :</h3>
<ul>
<li>
        <strong>Automatically convert types</strong></p>
<div style="border:1px dotted #909090;background-color:#f7f7f7;overflow:auto;padding:4px;">
<pre><code>
implicit def convert(javaMap: Hashtable[String, String]) = {
    Map.empty ++ new MapWrapper[String, String]() {
        def underlying = javaMap
    }
}
</code></pre>
</div>
<p>To automatically convert a java.util.Hashtable (java.util.Properties) into a scala Map,<br />
Example :
<div style="border:1px dotted #909090;background-color:#f7f7f7;overflow:auto;padding:4px;">
<pre><code>
val hashtable: java.util.Hastable[String, String] = new java.util.Hashtable[String, String]()
hashtable.put("some_key", "some_value")

val map = hashtable.asInstanceOf[Map[String, String]]
</code></pre>
</div>
</li>
<li>
        <strong>A var that contains a method that returns the ldap properties file</strong></p>
<div style="border:1px dotted #909090;background-color:#f7f7f7;overflow:auto;padding:4px;">
<pre><code>
object SimpleLDAPSearch {
    var propertiesFile: () =&#62; String = {
        () =&#62; "DEFAULT_PROPERTIES_FILE.properties"
    }
..
// The SimpleLDAPSearch singleton propertiesFile method can be override in any moment
SimpleLDAPSearch.propertiesFile = () =&#62; "/tmp/ldap.properties"
</code></pre>
</div>
</li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Arkeia Enterprise Backup lends more Enterprise Credibility to Ubuntu Server]]></title>
<link>http://siliconewhisperer.wordpress.com/2009/11/15/arkeia-enterprise-backup-lends-more-enterprise-credibility-to-ubuntu-server/</link>
<pubDate>Sun, 15 Nov 2009 05:25:56 +0000</pubDate>
<dc:creator>Ernest</dc:creator>
<guid>http://siliconewhisperer.wordpress.com/2009/11/15/arkeia-enterprise-backup-lends-more-enterprise-credibility-to-ubuntu-server/</guid>
<description><![CDATA[In one of my older articles, I explained how Ubuntu Server has slowly made significant inroads in ma]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><img class="alignleft" src="http://www.arkeia.com/media/images/logos/Ubuntu_small.png" alt="" width="138" height="160" />In one of my older articles, I explained how Ubuntu Server has slowly made significant inroads in many enterprise data centers. Ubuntu has been the favorite distribution of many system administrators, architects and various other IT staff. It was these fans of the Linux distribution that brought Ubuntu into their data centers and slowly deployed Ubuntu into ever increasing roles. I have seen Ubuntu Server deployed in roles from simple kiosks and desktops to full blown web server and database farms. Many senior level managers do not even know that key components of their infrastructures are running on Ubuntu Server.</p>
<p>Most data centers use an enterprise backup platform like Symantec&#8217;s NetBackup. These platforms are often very complex and extremely expensive to operate. Without a solid comprehensive backup strategy and platform, however, you place your disaster recovery and business continuity in great risk. For those users of Ubuntu Server who do not wish to incur the expense and complexity of NetBackup and other similar platforms, Arkeia Software has released a free version of their popular enterprise backup server for Ubuntu Server. This strategic move lends Ubuntu more Enterprise Credibility while also giving Arkeia more visibility and market share within the enterprise backup market. Lest you think that this is a watered down version of the product line, Arkeia has spelled out what is available to Ubuntu Server users along with the capabilities of the platform.</p>
<p>From the site:</p>
<blockquote><p>Arkeia Software provides packages specifically designed for Ubuntu distributions, both 32bit and 64-bit architectures, along with specialized agents for the protection of <a href="http://www.arkeia.com/en/products/arkeia-network-backup/backup-agent/application-agent">applications </a>and <a href="http://www.arkeia.com/en/products/arkeia-network-backup/backup-agent/database-agent">databases </a>running on Ubuntu, such as Oracle, MySQL, PostgreSQL, and LDAP.  Ubuntu is also a supported platform for Arkeia Network Backup <a href="http://www.arkeia.com/en/products/arkeia-network-backup/disaster-recovery">Disaster Recovery</a> for Linux, which enables bare-metal restores of entire systems.</p>
<h3>Arkeia Network Backup: Enterprise Edition for Ubuntu</h3>
<p>Arkeia Software provides a fully-licensed, free version of Arkeia Network Backup that is available in the Ubuntu 8.04 LTS software repository. With a few clicks from within the GUI, or just a simple command using the &#8216;apt-get&#8217; utility, Ubuntu users can quickly deploy a fully-featured backup server. Arkeia Network Backup: Enterprise Edition for Ubuntu offers an advanced network backup solution with the ease-of-use and deployment that Ubuntu users are accustomed to.</p>
<p><strong>What&#8217;s Included</strong></p>
<ul>
<li>Arkeia Network Backup Server for Ubuntu 8.04 LTS</li>
<li>2 Client Agents supporting Windows workstations and desktops, and a vast majority of Linux machines, Mac OS X and BSD computers<!--EndFragment--></li>
<li>1 Drive license for disk-based (up to 250GB) or tape backups</li>
<li>Support via online <a href="http://forum.arkeia.com/">forums</a>, <a href="http://www.arkeia.com/en/support/knowledge-base">knowledgebase</a>, and <a href="http://wiki.arkeia.com/mediawiki/index.php/Ubuntu-Enterprise-Backup">wiki</a></li>
</ul>
<div>Learn more about <a href="http://www.arkeia.com/en/products/arkeia-network-backup">Arkeia Network Backup.</a></div>
<div></div>
</blockquote>
<h3>Arkeia and Open Source</h3>
<p>Arkeia Software was the first professional network backup solution for Linux and has supported the open source community since 1999. Today, Arkeia continues to provide the deepest and broadest support for Linux and open source with more than 100 platforms supported. Arkeia acknowledges the work of thousands of Linux users who have donated their time and expertise towards the goal of making Linux and open source software a viable alternative.</p>
<div>Lean more about Arkeia&#8217;s <a href="http://www.arkeia.com/en/solutions/open-source-solutions">open source solutions</a>.</div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[BEA WebLogic: Number Format Exception while starting WebLogic Server]]></title>
<link>http://dullaertdknowledge.wordpress.com/2009/11/13/bea-weblogic-number-format-exception-while-starting-weblogic-server/</link>
<pubDate>Fri, 13 Nov 2009 11:48:04 +0000</pubDate>
<dc:creator>dullaertd</dc:creator>
<guid>http://dullaertdknowledge.wordpress.com/2009/11/13/bea-weblogic-number-format-exception-while-starting-weblogic-server/</guid>
<description><![CDATA[When starting the Admin Server of our domain we encountered following error: ####&lt;Nov 13, 2009 11]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>When starting the Admin Server of our domain we encountered following error:</p>
<pre style="padding-left:30px;">####&#60;Nov 13, 2009 11:58:23 AM CET&#62; &#60;Critical&#62; &#60;WebLogicServer&#62; &#60;machine-name&#62; &#60;as&#62; &#60;Main Thread&#62; &#60;&#60;WLS Kernel&#62;&#62; &#60;&#62; &#60;&#62; &#60;12
58109903043&#62; &#60;BEA-000386&#62; &#60;Server subsystem failed. Reason: java.lang.NumberFormatException: null
java.lang.NumberFormatException: null
        at java.lang.Integer.parseInt(Integer.java:415)
        at java.lang.Integer.parseInt(Integer.java:497)
        at weblogic.ldap.EmbeddedLDAP.validateVDEDirectories(EmbeddedLDAP.java:1035)
        at weblogic.ldap.EmbeddedLDAP.start(EmbeddedLDAP.java:212)
        at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
&#62;</pre>
<p>The first thing we tried is restoring a backup of the ldap folder. This backup can be found at: ../<em>domain-name</em>/server/<em>adminserver</em>/data/ldap/backup/ and should be restored at ../<em>domain-name</em>/server/<em>adminserver</em>/data/ldap/ldapfiles.</p>
<p>When this was not working, we kept looking and stumbled upon a site that told us that this error could be caused when the volume that contains these files is running full. WebLogic will corrupt these files. And the solution is to add &#8216;replica.num=0&#8242; to the ../<em>domain-name</em>/server/<em>adminserver</em>/data/ldap/config/replicas.prop file. Or just remove this file..</p>
<p>Source: <a href="http://ghattus.com/2008/10/number-format-exception-while-starting-weblogic-server.html">http://ghattus.com/2008/10/number-format-exception-while-starting-weblogic-server.html</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Active Directory Tutorial]]></title>
<link>http://cn180.wordpress.com/2009/11/12/active-directory-tutorial/</link>
<pubDate>Thu, 12 Nov 2009 06:37:33 +0000</pubDate>
<dc:creator>Phil Fenton</dc:creator>
<guid>http://cn180.wordpress.com/2009/11/12/active-directory-tutorial/</guid>
<description><![CDATA[I found this article online it&#8217;s a nice summarization of Active Directory that may be useful i]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I found this article online it&#8217;s a nice summarization of Active Directory that may be useful in helping you understand AD and LDAPs in general. <a href="http://bit.ly/3cZkps">http://bit.ly/3cZkps</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[validació de moodle en base de dades externa]]></title>
<link>http://lmunoza.wordpress.com/2009/11/08/validacio-de-moodle-en-base-de-dades-externa/</link>
<pubDate>Sun, 08 Nov 2009 18:54:00 +0000</pubDate>
<dc:creator>lmunoza</dc:creator>
<guid>http://lmunoza.wordpress.com/2009/11/08/validacio-de-moodle-en-base-de-dades-externa/</guid>
<description><![CDATA[Aprofitant l&#8217;entrada de blog anterior ja poso una nova entrada de validació de la base de dade]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Aprofitant l&#8217;entrada de blog anterior ja poso una nova entrada de validació de la base de dades de moodle no en el servidor de ldap com estava anteriorment&#160; sino a la base de dades del servidor de la intraweb de centre, en aquest cas creada sobre postnuke. No crec que la variació de l&#8217;aplicatiu de gestió de continguts sigui un impediment per que sigui de manera molt aproximada amb aquestes dades.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://lmunoza.wordpress.com/files/2009/11/moddle-base-dades-externa.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://lmunoza.wordpress.com/files/2009/11/moddle-base-dades-externa.jpg?w=300" /></a></div>
<div class="separator" style="clear:both;text-align:center;"></div>
<div class="separator" style="clear:both;text-align:left;">Amb aquesta configuració ja permet realitzar la validació dels usuaris dintre de la base de dades de altre aplicatiu. En el meu cas particular, la base de dades es troba al mateix ordinador que el moodle, aquesta és la raó per posar localhost com direcció del servidor de la base de dades.</div>
<div class="separator" style="clear:both;text-align:left;"></div>
<div class="separator" style="clear:both;text-align:left;">Una vegada es posa un nom d&#8217;usuari de la base de dades i el seu password s&#8217;ha de finalitzar amb la introducció de dades com el mail i nom d&#8217;usuari i cognom, de la mateixa manera que al post anterior.</div>
<div class="separator" style="clear:both;text-align:left;"></div>
<div class="separator" style="clear:both;text-align:left;"></div>
<div class="separator" style="clear:both;text-align:center;"><a href="http://lmunoza.wordpress.com/files/2009/11/moddle-base-dades-externa-importacio.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://lmunoza.wordpress.com/files/2009/11/moddle-base-dades-externa-importacio.jpg?w=300" /></a></div>
<div class="separator" style="clear:both;text-align:center;"></div>
<div class="separator" style="clear:both;text-align:left;">Per evitar que l&#8217;usuari tingues que omplir aquestes dades de les que parlem només caldria associar el&#160; nom d&#8217;usuari amb el nom de la columna corresponent al l&#8217;altre base de dades&#160;i així ja estaria introduit com la resta de dades.</div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[conexión moodle - ldap]]></title>
<link>http://lmunoza.wordpress.com/2009/11/08/conexion-moodle-ldap/</link>
<pubDate>Sun, 08 Nov 2009 18:44:00 +0000</pubDate>
<dc:creator>lmunoza</dc:creator>
<guid>http://lmunoza.wordpress.com/2009/11/08/conexion-moodle-ldap/</guid>
<description><![CDATA[Donat que ja hem montat un servidor de ldap, per tal de centralitzar accesos de diferents sistemes o]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Donat que ja hem montat un servidor de ldap, per tal de centralitzar accesos de diferents sistemes operatius que tenim al centre, linux, windows i finalment les diferents aplicacions web i proxy que es podran validar dintre d&#8217;aquesta base de dades de ldap per tal de tenir una gestió centralitzada de tota la llista d&#8217;usuaris.</p>
<p>Partim que ja tenim un servidor de ldap, una instal·lació de moodle realitzada i anem fent els passos necessaris per determinar que l&#8217;acces només vindrà donat via base de dades de ldap.</p>
<p>Anem a moodle i a la part d&#8217;usuaris i autenticació revisem les opcions:
<div class="separator" style="clear:both;text-align:center;"><a href="http://lmunoza.wordpress.com/files/2009/11/users.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://lmunoza.wordpress.com/files/2009/11/users.jpg?w=213" /></a></div>
<div class="separator" style="clear:both;text-align:center;"></div>
<div align="center" class="separator" style="border-bottom:medium none;border-left:medium none;border-right:medium none;border-top:medium none;clear:both;text-align:left;"><a href="http://lmunoza.wordpress.com/files/2009/11/autenticacic3b3n.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://lmunoza.wordpress.com/files/2009/11/autenticacic3b3n.jpg?w=300" /></a></div>
<div align="center"></div>
<p>En el meu cas es suficient realitzar la següent configuració de paràmetres, el servidor de ldap com ldap://servidor.intracentre o la seva ip i la resta de paràmetres. El password serà el corresponent a la base de dades de ldap.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://lmunoza.wordpress.com/files/2009/11/autenticacion-ldap.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://lmunoza.wordpress.com/files/2009/11/autenticacion-ldap.jpg?w=300" /></a></div>
<div class="separator" style="clear:both;text-align:center;"></div>
<div class="separator" style="clear:both;text-align:left;">Ja només queda guardar</div>
<p>Obrir una nova sessió, en el meu cas en un altre navegador, per mantenir la sessió d&#8217;administrador amb Firefox i amb Google Chrome la del client, alumne de moodle</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://lmunoza.wordpress.com/files/2009/11/usuari-ldap.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://lmunoza.wordpress.com/files/2009/11/usuari-ldap.jpg?w=209" /></a></div>
<div class="separator" style="clear:both;text-align:center;"></div>
<div class="separator" style="clear:both;text-align:left;">L&#8217;usuari tecno6 és un alumne que correspon a la base de ldap, és valida a ldap i donat que coincideix contrasenya i usuari passa a la pantalla següent:</div>
<div class="separator" style="clear:both;text-align:left;"></div>
<div class="separator" style="clear:both;text-align:left;"><a href="http://lmunoza.wordpress.com/files/2009/11/alta-moodle-de-ldap.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://lmunoza.wordpress.com/files/2009/11/alta-moodle-de-ldap.jpg?w=300" /></a></div>
<div class="separator" style="clear:both;text-align:left;"></div>
<div class="separator" style="clear:both;text-align:left;">Aquestes són les dades que s&#8217;han d&#8217;omplir ara de l&#8217;alumne, nom , cognom, direcció correu electrònic, població i pais.</div>
<div class="separator" style="clear:both;text-align:left;"></div>
<div class="separator" style="clear:both;text-align:left;">Quan l&#8217;alumne posa aquestes dades, ja només queda que realitzi la confirmació al mail que s&#8217;ha posat i ja es usuari de moodle validat a la base de ldap. ç</div>
<div class="separator" style="clear:both;text-align:left;"></div>
<div class="separator" style="clear:both;text-align:left;">Atenció, si cau el servidor de ldap, l&#8217;alumne no es podrà validar.</div>
<div class="separator" style="clear:both;text-align:left;"></div>
<div class="separator" style="clear:both;text-align:left;">Quedaria afinar i que moodle agafes totes les dades de ldap pero, fins ara aquesta solució ja em va bé per deixar-me centralitzada totes les dades d&#8217;alumnes.</div>
<div class="separator" style="clear:both;text-align:left;"></div>
<div class="separator" style="clear:both;text-align:left;"></div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Reading paged LDAP results with PHP is a show-stopper]]></title>
<link>http://sgehrig.wordpress.com/2009/11/06/reading-paged-ldap-results-with-php-is-a-show-stopper/</link>
<pubDate>Fri, 06 Nov 2009 14:52:20 +0000</pubDate>
<dc:creator>Stefan Gehrig</dc:creator>
<guid>http://sgehrig.wordpress.com/2009/11/06/reading-paged-ldap-results-with-php-is-a-show-stopper/</guid>
<description><![CDATA[I was writing the schema introspection code for Zend_Ldap when I came around a problem with Active D]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I was writing the schema introspection code for <code>Zend_Ldap</code> when I came around a problem with Active Directory’s <code>MaxPageSize</code> restriction. By default Active Directory allows only 1000 items to be returned on a single query, a number which is easily exceeded when reading an Active Directory’s classes and especially attributes from the schema tree. OK – one option would be to increase the <code>MaxPageSize</code> variable, but as the component should be usable on every Active Directory server I couldn’t go for that.</p>
<p>The second option that seemed possible makes use of the paged result sets that Active Directory returns on a query. This way led me into the world of LDAP server controls and deep into the <code>ext/ldap</code> source code. There is astonishingly little information on the topic of paged result sets and LDAP server controls in respect of PHP and <code>ext/ldap</code>. To be honest I assume that only one person really looked into this area seriously and even came up with a solution: Iñaki Arenaza (<a href="http://iarenaza.blogs.mondragon.edu/" target="_blank">Blog</a>, <a href="http://twitter.com/iarenaza" target="_blank">Twitter</a>, <a href="http://www.facebook.com/profile.php?id=769854628" target="_blank">Facebook</a>, <a href="http://www.linkedin.com/in/iarenaza" target="_blank">LinkedIn</a>). His information provided <a href="http://moodle.org/mod/forum/discuss.php?d=28791" target="_blank">here</a> is the foundation of this article – the discoveries are absolutely not my work, they are all based on what Iñaki Arenaza dug out. I just wanted to bring a little light into this very specific topic (and summarize what I’ve answered on <a href="http://stackoverflow.com/questions/1473075/enumerate-all-users-in-ldap-with-php/1476287#1476287" target="_blank">stackoverflow.com</a>).</p>
<p>To make it short right from the beginning: <strong>it&#8217;s currently not possible to use paged results from an Active Directory with an unpatched PHP (<code>ext/ldap</code>)</strong>.</p>
<p>Let’s take a closer look at what’s happening.</p>
<p>Active Directory uses a server control to accomplish server-side result paging. This control is described in <a href="http://www.ietf.org/rfc/rfc2696.txt">RFC 2696 &#8220;LDAP Control Extension for Simple Paged Results Manipulation&#8221;</a> . LDAP controls, which come in the flavors “server” and “client”, are extensions to the LDAP protocol to provide enhancements – result paging is one example, password policy is another one. Generally <code>ext/ldap</code> offers an access to LDAP control extensions via its <a href="http://fr.php.net/manual/en/function.ldap-set-option.php"><code>ldap_set_option()</code></a> and the<code>LDAP_OPT_SERVER_CONTROLS</code> and <code>LDAP_OPT_CLIENT_CONTROLS</code> option respectively. To setup the paged control we do need the control-oid, which is <code>1.2.840.113556.1.4.319</code>, and we need to know how to encode the control-value (this is described in the <a href="http://www.ietf.org/rfc/rfc2696.txt">RFC</a>). The value is an octet string wrapping the BER-encoded version of the following SEQUENCE (copied from the RFC):</p>
<pre>realSearchControlValue ::= SEQUENCE {
    size    INTEGER (0..maxInt),
                     -- requested page size from client
                     -- result set size estimate from server
    cookie  OCTET STRING
}</pre>
<p>So we can setup the control prior to executing the LDAP desired query:</p>
<pre>$pageSize    = 100;
$pageControl = array(
    // the control-oid
    'oid'        =&#62; '1.2.840.113556.1.4.319',
    // the operation should fail if the server is not able to support this control
    'iscritical' =&#62; true,
    // the required BER-encoded control-value
    'value'      =&#62; sprintf ("%c%c%c%c%c%c%c", 48, 5, 2, 1, $pageSize, 4, 0)
);</pre>
<p>This allows us to send a paged query to the LDAP/AD server. But how do we know if there are more pages to follow and how do we have to send a query to get the next page of our result set?</p>
<p>The server responds with a result set that includes the required paging information &#8211; but PHP lacks a method to retrieve exactly this information from the result set. In fact ext/ldap provides the required function (<code><a href="http://fr.php.net/manual/en/function.ldap-parse-result.php" target="_blank">ldap_parse_result()</a></code>) but it fails to expose the required seventh and last argument <code>serverctrlsp</code> from the C function <code>ldap_parse_result()</code> in the <a href="http://www.ietf.org/rfc/rfc1823.txt" target="_blank">LDAP API</a>, which contains exactly the information we need to requery for consecutive pages. If we had this argument available in our PHP code, using paged controls would be straight forward:</p>
<pre>$l = ldap_connect('somehost.mydomain.com');
$pageSize    = 100;
$pageControl = array(
    'oid'        =&#62; '1.2.840.113556.1.4.319',
    'iscritical' =&#62; true,
    'value'      =&#62; sprintf ("%c%c%c%c%c%c%c", 48, 5, 2, 1, $pageSize, 4, 0)

);
$controls = array($pageControl);

ldap_set_option($l, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_bind($l, 'CN=bind-user,OU=my-users,DC=mydomain,DC=com', 'bind-user-password');

$continue = true;
while ($continue) {
    ldap_set_option($l, LDAP_OPT_SERVER_CONTROLS, $controls);
    $sr = ldap_search($l, 'OU=some-ou,DC=mydomain,DC=com', 'cn=*', array('sAMAccountName'), null, null, null, null);
    // there's the rub
    ldap_parse_result ($l, $sr, $errcode, $matcheddn, $errmsg, $referrals, $serverctrls);
    if (isset($serverctrls)) {
        foreach ($serverctrls as $i) {
            if ($i["oid"] == '1.2.840.113556.1.4.319') {
                    $i["value"]{8}   = chr($pageSize);
                    $i["iscritical"] = true;
                    $controls        = array($i);
                    break;
            }
        }
    }

    $info = ldap_get_entries($l, $sr);
    if ($info["count"] &#60; $pageSize) {
        $continue = false;
    }

    for ($entry = ldap_first_entry($l, $sr); $entry != false; $entry = ldap_next_entry($l, $entry)) {
        $dn = ldap_get_dn($l, $entry);
    }
}</pre>
<p>As you see, the only option to make all this work, is to mess with the <code>ext/ldap</code> source code and compile your own extension. Iñaki Arenaza provides several patches that can be applied to the PHP source to make patching a lot easier. The patches can be found <a href="http://www.eteo.mondragon.edu/descargas/php-ldap/" target="_blank">here</a> (last one for PHP 5.2.10 from June 24<sup>th</sup> 2009) and there is an accompanying <a href="http://iarenaza.blogs.mondragon.edu/2007/07/08/en-que-gasto-mi-tiempo-ultimamente-moodle-ldap-php-y-c/" target="_blank">blog post</a> available. Iñaki Arenaza even opened <a href="http://bugs.php.net/bug.php?id=34492" target="_blank">an issue</a> in the PHP bug tracker on September 13<sup>th</sup> 2005 offering his help – but there has been no reaction from the developer’s side. What a great pity.</p>
<p>So, if you have to use paged result sets in an Active Directory environment from within a PHP application you can choose between:</p>
<ul>
<li>patch your <code>ext/ldap</code> and compile your own extension as described in this article</li>
<li><a href="http://support.microsoft.com/?scid=kb;en-us;315071" target="_blank">raise the MaxPageSize limit</a> in your Active Directory server</li>
<li>use a completely different approach bypassing <code>ext/ldap</code> and make use of the appropriate COM components (ADODB) as described <a href="http://us3.php.net/manual/en/function.ldap-search.php#73636" target="_blank">here</a> (<em>this only works on Windows machines</em>)</li>
</ul>
<p>It could have been so easy, if…, yes if only the PHP developers considered applying the available patch to the <code>ext/ldap</code> source code.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Don't Try This At Home]]></title>
<link>http://bug4free.wordpress.com/2009/11/06/dont-try-this-at-home/</link>
<pubDate>Fri, 06 Nov 2009 14:25:33 +0000</pubDate>
<dc:creator>Hubert</dc:creator>
<guid>http://bug4free.wordpress.com/2009/11/06/dont-try-this-at-home/</guid>
<description><![CDATA[When it comes to software, I like to try all available features (even the most obscure ones) and som]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>When it comes to software, I like to try all available features (even the most obscure ones) and sometimes I end up in a situation where my chances of recovery seem pretty slim. I recently managed just that by setting my <a title="OpenSSO" href="https://opensso.dev.java.net" target="_blank">OpenSSO</a> top realm (/) to <em>inactive</em>&#8230;<br />
Why would I do such thing I hear you say? Well I was trying to solve some issues related to our OpenID 2.0 extension and was experimenting with various realms, so there you have it&#8230;</p>
<p>The result of this great inspiration of mine is that I could not log anymore to the admin console; a tad annoying&#8230;<br />
The solution (thanks to Shivaram!) is to edit the LDAP configuration tree and change the value of <em>ou=services,dc=opensso,dc=java,dc=net</em> and set it back to active. That&#8217;s it, you&#8217;re in!</p>
<p>Now me thinks we should change the console so as to prevent this from being possible&#8230;</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Fatal error : Call to undefined function: ldap_connect() ]]></title>
<link>http://2paisasbyviggy.wordpress.com/2009/10/29/fatal-error-call-to-undefined-function-ldap_connect/</link>
<pubDate>Thu, 29 Oct 2009 07:26:49 +0000</pubDate>
<dc:creator>viggyprabhu</dc:creator>
<guid>http://2paisasbyviggy.wordpress.com/2009/10/29/fatal-error-call-to-undefined-function-ldap_connect/</guid>
<description><![CDATA[I got this error when I was trying to get my drupal installation authenticate using the local ldap d]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I got this error when I was trying to get my drupal installation authenticate using the local ldap directory. Initially, I had thought that I was getting error because of my ldap settings. Then I enabled error reporting on my site, that is when this error was displayed to me. </p>
<p>This error is caused, I suppose due to the missing package php5-ldap in the system. After I installed this package using apt-get and restarted apache2, LDAP authentication wroked fine.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Authenticating squid using lotus domino ldap]]></title>
<link>http://cybersecblog.wordpress.com/2009/10/28/authenticating-squid-using-lotus-domino-ldap/</link>
<pubDate>Wed, 28 Oct 2009 10:57:00 +0000</pubDate>
<dc:creator>N!x</dc:creator>
<guid>http://cybersecblog.wordpress.com/2009/10/28/authenticating-squid-using-lotus-domino-ldap/</guid>
<description><![CDATA[The story behind the project: &#8220;Unless you are willing to drench yourself in your work beyond t]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><h1>The story behind the project:</h1>
<div><em>&#8220;Unless you are willing to drench yourself in your work beyond the capacity of the average man, you are just not cut out for positions at the top.&#8221; &#8211; </em><strong>J.C. Penny<br />
</strong></div>
<p>This project was one of my all time best results. When I was first given this project, I had no previous knowledge on Squid or Lotus Domino, yet I took up the challenge. On Day 1, I was given the whole picture of the project at the client side. They had recently migrated from their mail system to Lotus iNotes. They were using OpenLDAP to authenticate all the users for internet and mail.</p>
<p>Since Lotus iNotes comes with Lotus Domino LDAP for authenticating users, this created a problem for the client. Now the users must provide 2 separate authentication credentials for internet and mail. They sought my Company&#8217;s expertise to help them converge the authentication system for internet and mail using Lotus Domino LDAP.</p>
<p>I jumped in to analyse the problem. After a long and tiring research, understood that a lot of people had the same issue, and it seems no one has been successful in using Domino LDAP to authenticate Squid clients (except one, which was like finding a needle in a haystack). All the gained information helped me to authenticate Squid using OpenLDAP only. Armed with these information, i started the project. After trying each and every combination unsuccessfully, I started loosing hope that there could be a solution after all. But that single find (needle) was a major boost to my confidence. I was sure that there is a solution. So, after some serious discussions with my senior, I ran netcat (my savior) and captured the output that Squid was sending. Now, using the same technique I captured what ldapsearch was sending (ohhh i forgot to tell you that ldapsearch was workign perfectly fine with Domino LDAP). And LO!!! There lies the problem, a very very very simple issue. I couldnt believe it.<!--more--></p>
<p><a name="more"></a><br />
The issue was that Domino accepts credentials in the form of <em><strong>&#60;username&#62;space&#60;password&#62;</strong></em> while squid send the data in the form of <em><strong>uid=&#60;username&#62;,&#60;password&#62;</strong></em>. Now, with this information, i started a code review of squid_ldap_auth.c file and found the culprits hiding at various spots. I edited the necessary field (dont worry i will share it) and after remaking the file, SUCCESS!!!! Now squid clients are getting authenticated using Domino LDAP. SSL (squid-LDAP) also works perfectly fine.</p>
<h1>Solution</h1>
<ol>
<li>First open the <strong>squid_ldap_auth.c</strong> file situated in <em>squid-version/helpers/basic_auth/LDAP/</em></li>
<li>Find the line as shown below.<a href="http://lh6.ggpht.com/_fteegur5w74/Sugja7KiZDI/AAAAAAAACBI/Vi6MXCENg5s/s1600-h/Figure1-uid%5B3%5D.jpg"><img title="Figure1-uid" src="http://lh4.ggpht.com/_fteegur5w74/SugjbyaUboI/AAAAAAAACBM/7tFt48XuDJ4/Figure1-uid_thumb%5B1%5D.jpg?imgmax=800" border="0" alt="Figure1-uid" width="335" height="230" /></a></li>
<li>Now, remove “uid” so that the default value for userattr is NULL<a href="http://lh3.ggpht.com/_fteegur5w74/SugjcgBc8RI/AAAAAAAACBQ/6UKEMNo4Mb8/s1600-h/Figure2-uid%5B3%5D.jpg"><img title="Figure2-uid" src="http://lh4.ggpht.com/_fteegur5w74/SugjdhFBVrI/AAAAAAAACBU/dp3Bua7N0Us/Figure2-uid_thumb%5B1%5D.jpg?imgmax=800" border="0" alt="Figure2-uid" width="339" height="201" /></a></li>
<li>Next, find the line where the credentials are bound together and sent to the port for transmission. Here you will find that the credentials are bound with “=” and “,” added to it. This is unnecessary for Lotus Domino LDAP.<a href="http://lh5.ggpht.com/_fteegur5w74/SugjePBQwTI/AAAAAAAACBY/CQFDup6_lHc/s1600-h/Figure3-userattr%5B4%5D.jpg"><img title="Figure3-userattr" src="http://lh6.ggpht.com/_fteegur5w74/Sugje7cm9kI/AAAAAAAACBc/OqLeTngP0t0/Figure3-userattr_thumb%5B2%5D.jpg?imgmax=800" border="0" alt="Figure3-userattr" width="446" height="175" /></a></li>
<li>The edited line should be as given below (without the “=” and “,”)<a href="http://lh3.ggpht.com/_fteegur5w74/Sugjf9kvLfI/AAAAAAAACBg/dIa4Lu9n51A/s1600-h/Figure4-userattr%5B4%5D.jpg"><img title="Figure4-userattr" src="http://lh5.ggpht.com/_fteegur5w74/SugjghLG9RI/AAAAAAAACBk/3iMzTsDNpvs/Figure4-userattr_thumb%5B2%5D.jpg?imgmax=800" border="0" alt="Figure4-userattr" width="478" height="186" /></a></li>
<li>Now, the file is ready to be deployed. But, to acknowledge the hard work I have put into it, add the following lines into it as well.</li>
</ol>
<p><a href="http://lh4.ggpht.com/_fteegur5w74/Sugjhdta5sI/AAAAAAAACBo/USxG25QDZ_w/s1600-h/Figure5-changes%5B3%5D.jpg"><img title="Figure5-changes" src="http://lh3.ggpht.com/_fteegur5w74/SugjiLR6zAI/AAAAAAAACBs/zMc0sQUD4MQ/Figure5-changes_thumb%5B1%5D.jpg?imgmax=800" border="0" alt="Figure5-changes" width="569" height="214" /></a></p>
<h1>Conclusion</h1>
<p>I hope my solution has proved to be helpful for you. If by any chance you stumble upon an issue while implementing this project, feel free to get in touch with me. Together, we will drill down to the core and find the solution for the problem.</p>
<p>Dont forget to add my blog to your RSS.</p>
<h1><strong><span style="color:#804000;font-size:medium;">Appendix</span></strong></h1>
<p>I am also attaching the netcat outputs, which helped me identify the issue.</p>
<ol>
<li>Netcat output of Ldapsearch – Working<a style="text-decoration:none;" href="http://lh5.ggpht.com/_fteegur5w74/Sugji1cRAQI/AAAAAAAACBw/_rrZcnRIobc/s1600-h/ldapseachworking%5B8%5D.jpg"><img title="ldapseachworking" src="http://lh3.ggpht.com/_fteegur5w74/Sugjju5QvaI/AAAAAAAACB0/5SK3Fk-fj_c/ldapseachworking_thumb%5B4%5D.jpg?imgmax=800" border="0" alt="ldapseachworking" width="557" height="128" /></a></li>
<li>Netcat outout of Squid – Not working. But by comparing both, we can identify the issue.<a href="http://lh3.ggpht.com/_fteegur5w74/SugjkWZ1xpI/AAAAAAAACB4/2bN-VibV7u8/s1600-h/ncandsquid3%5B4%5D.jpg"><img title="ncandsquid3" src="http://lh3.ggpht.com/_fteegur5w74/SugjlWeNjRI/AAAAAAAACB8/UhtICI8JwCo/ncandsquid3_thumb%5B2%5D.jpg?imgmax=800" border="0" alt="ncandsquid3" width="565" height="121" /></a></li>
</ol>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Extending Active Directory to the Cloud]]></title>
<link>http://conformity.wordpress.com/2009/10/17/extending-active-directory-to-the-cloud/</link>
<pubDate>Sat, 17 Oct 2009 22:39:26 +0000</pubDate>
<dc:creator>Scott Bils</dc:creator>
<guid>http://conformity.wordpress.com/2009/10/17/extending-active-directory-to-the-cloud/</guid>
<description><![CDATA[One of the use cases we&#8217;re almost universally supporting across our midsize enterprise custome]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>One of the use cases we&#8217;re almost universally supporting across our midsize enterprise customer base here at <a href="http://www.conformity-inc.com" target="_blank">Conformity</a> is integration with Microsoft <a href="http://http://www.microsoft.com/windowsserver2003/technologies/directory/activedirectory/default.mspx" target="_blank">Active Directory (AD)</a>, and providing the ability to extend and link employee, role and organizational data with identity stores contained in leading SaaS applications such as <a href="http://www.salesforce.com" target="_blank">Salesforce.com</a>, <a href="http://www.netsuite.com" target="_blank">NetSuite</a>, <a href="http://www.google.com/apps" target="_blank">Google Apps</a> and others.  With our AD connector, customers of the <a href="http://www.conformity-inc.com/solution/" target="_blank">Conformity platform</a> are extending capabilities today in two major areas:</p>
<ul>
<li><strong>User provisioning / deprovisioning &#8211; </strong>by normalizing and synchronizing role and permissions models across AD and Conformity and through deploying our event monitoring capabilities customers can automate user provisioning, deprovisioning and change management activities.    When a new employee is onboarded and set up within AD, access and permissions to cloud services appropriate for the employee&#8217;s role are automatically provisioned via Conformity.  For example, when a new outside sales rep joins the organization, when added in AD they then can also be provisioned against Salesforce.com, Xactly and Google Apps with appropriate access and permissions.   When the sales rep changes title or role, or leaves the organization, changes in AD also then trigger appropriate changes in cloud application access and permissions.  In effect, we&#8217;re providing users a cloud provisioning extension for AD that enables IT to extend access policies and controls to the cloud.</li>
<li><strong>Chargeback models &#8211; </strong>integration of department and other organizational identifiers between AD and Conformity&#8217;s role model also streamlines our customers ability to automate extension of internal chargeback and financial management models to cloud applications.  By linking SaaS administrative siloes to AD  via Conformity, enterprises can track and manage departmental usage not just at the application level, but also within specific modules within the cloud services themselves.</li>
</ul>
<p>In addition to dramatically reducing administrative headaches, synchronizing and normalizing identity data across AD and major cloud applications is also enabling them to streamline audit prep activities, reduce operational costs and strengthen access control and security.  More to come on this&#8230;</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[silverlight und wcf]]></title>
<link>http://silverlightblogger.wordpress.com/2009/10/17/silverlight-und-wcf/</link>
<pubDate>Sat, 17 Oct 2009 12:55:05 +0000</pubDate>
<dc:creator>silverlightblogger</dc:creator>
<guid>http://silverlightblogger.wordpress.com/2009/10/17/silverlight-und-wcf/</guid>
<description><![CDATA[silverlight und wcf&#8230; das ist eigentlich ein recht umfangreichens thema. ich versuche trotzdem ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>silverlight und wcf&#8230; das ist eigentlich ein recht umfangreichens thema. ich versuche trotzdem mal möglichst zusammenfassen meine bisherigen erfahrungen zu schildern.</p>
<p>wcf wurde nicht durch silverlight eingeführt und enthält deutlich mehr, als das, was silverlight in dem zusammenhang bietet. d.h. silverlight unterstützt zwar einige wcf funktionen, kann aber bei weitem nicht alles. es ist also nicht grundsätzlich möglich vorhandene services zu nutzen.</p>
<p>silverlight bietet die möglichkeit service calls abzusichern, allerdings nur mit UserNameOverTransport! nutzt man das, dann ist außerdem https notwendig! man muss dann also den iis benutzen, weil der development server des vs ssl garnicht unterstützt.</p>
<p>also fix ssl im iis aufsetzen, dafür gibts einige tutorials im netz! ein login sollte grundsätzlich mit ssl umgesetzt werden, weil die credentials, auch mit der normalen windows forms authentifizierung sonst unverschlüsselt übertragen werden und das will wohl keiner.</p>
<p>wird usernameovertransport benutzt, dann muss man entweder einen membershipprovider auswählen, selbst einen schreiben oder usernamepasswordvalidator implementieren, was deutlich einfacher ist, als einen membershipprovider zu implementieren. membershipprovider gibts z.b. für den sql server oder für den ldap (unten zu sehen).</p>
<p>zum testen benutze ich einen eigenen usernamepasswordvalidator, dessen validierungs methode einfach nur &#8220;return;&#8221; enthält. so muss man am client nix verändern und kann die security eingeschaltet lassen.</p>
<p><code><br />
&#60;behaviors&#62;<br />
&#60;serviceBehaviors&#62;<br />
&#60;behavior name="MeinProjekt.SecureServiceBehavior"&#62;<br />
&#60;serviceCredentials&#62;<br />
&#60;!--userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="ADMembershipProvider" /--&#62;<br />
&#60;userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MeinProjekt.CustomUserNamePasswordValidator, Zeiterfassung.Web"/&#62;<br />
&#60;/serviceCredentials&#62;<br />
&#60;serviceAuthorization <strong>principalPermissionMode</strong>="<strong>None</strong>"/&#62; &#60;!-- nur unter bestimmten vorraussetzungen mit der windows forms authentication notwendig --&#62;<br />
&#60;serviceMetadata httpsGetEnabled="true" /&#62;<br />
&#60;serviceDebug includeExceptionDetailInFaults="true" /&#62;<br />
&#60;dataContractSerializer maxItemsInObjectGraph="6553600" /&#62;<br />
&#60;/behavior&#62;<br />
&#60;/serviceBehaviors&#62;<br />
&#60;/behaviors&#62;<br />
<code></p>
<p>zu dem principalpermissionmode: (vgl. https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=369445)<br />
der ist für mein projekt eigentlich nicht notwendig. ja quasi überflüssig ABER: wenn in der serviceklasse mithilfe der principal annotationen festgelegt werden soll, wer denn die aufgerufene funktion ausführen darf und wer nicht z.b. so:<br />
[PrincipalPermission(SecurityAction.Demand,  User = "Admin")]</p>
<p>dann kann es vorkommen, dass der aktuelle thread, den principal/user, der die funktion aufruft, garnicht kennt oder vergisst! (ich hatte vorher einen windows forms authentication ansatz mit eigener authentifizierung, da habe ich das noch mit principalpermission gemacht und da war das der fall). um das zu umgehen muss erst einmal in der web.config aspNetCompatibilityEnabled = true gesetzt werden. so:</p>
<p><code><br />
&#60;system.serviceModel&#62;<br />
&#60;serviceHostingEnvironment aspNetCompatibilityEnabled="true"/&#62;<br />
&#60;/system.serviceModel&#62;<br />
</code><br />
im konstruktor des webservice muss dann folgender code platziert werden:</p>
<p><code><br />
Thread.CurrentPrincipal = HttpContext.Current.User;<br />
</code></p>
<p>HttpContext.Current.User; &#60; hierfür ist aspNetCompatibilityEnabled notwendig!</p>
<p>dadurch wird dem ausgeführten thread der user zugeordnet, der den service aufgerufen hat (nachdem er bereits durch die forms authentification durch ist z.b. auch durch ein login). anschließend wird der nicht mehr "vergessen" durch das setzen des principalpermissionmodes auf none.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Quick Tip: How to search in Windows Active Directory from Linux with ldapsearch]]></title>
<link>http://randomerror.wordpress.com/2009/10/16/quick-tip-how-to-search-in-windows-active-directory-from-linux-with-ldapsearch/</link>
<pubDate>Fri, 16 Oct 2009 11:24:17 +0000</pubDate>
<dc:creator>sacx</dc:creator>
<guid>http://randomerror.wordpress.com/2009/10/16/quick-tip-how-to-search-in-windows-active-directory-from-linux-with-ldapsearch/</guid>
<description><![CDATA[Sometimes we need to query, under Linux, Active Directory for users/computers without accessing a re]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Sometimes we need to query, under <strong>Linux</strong>, <strong>Active Directory</strong> for users/computers without accessing a remote desktop. We can achieve that with ldapserch. First you should install first ldap-utils. In Debian or Ubuntu just run:</p>
<p><code>$ sudo apt-get install ldap-utils</code></p>
<p>The syntax for using ldapsearch:</p>
<p><code>ldapsearch -x -LLL -h [host] -D [user] -w [password] -b [base DN] -s sub "([filter])" [attribute list]</code></p>
<p>A simple example</p>
<p><code>$ ldapsearch -x -LLL -h host.example.com -D user -w password -b"dc=ad,dc=example,dc=com"  -s sub "(objectClass=user)" givenName<br />
</code></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[LDAP PAM Users]]></title>
<link>http://doctormo.wordpress.com/2009/10/08/ldap-pam-users/</link>
<pubDate>Thu, 08 Oct 2009 14:31:19 +0000</pubDate>
<dc:creator>Martin Owens</dc:creator>
<guid>http://doctormo.wordpress.com/2009/10/08/ldap-pam-users/</guid>
<description><![CDATA[Okay we had another go at trying to get LDAP working last night at our weekly MA Jam session. A big ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Okay we had another go at trying to get LDAP working last night at our weekly MA Jam session. A big thanks goes out to Tim and Scott for their help in researching clients and scripts and helping generally.</p>
<p>What I found was that the Ubuntu guide was less than optimal, I&#8217;ve failed three times trying to follow it. So I decided to use a different guide this time. The Debuntu LDAP guide:  <a href="http://www.debuntu.org/ldap-server-and-linux-ldap-clients">http://www.debuntu.org/ldap-server-and-linux-ldap-clients</a></p>
<p>this got me much further, I was able to run searches, import groups and users and learn a bit more about how LDAP actually works and how the admin user is specified properly. (probably the problem I was facing last time)</p>
<p>The remaining problem is that this Debuntu guide falls down when it comes to integrating PAM on the second page. The part where it went all wrong was when we installed the ldap and libnss packages and it asked us questions, answered in the way suggested. Then we had a look for /etc/pam_ldap.secrate and /etc/pam_ldap.conf and /etc/libnss-ldap.conf and so on, all these files DIDNT exist after the package configure as the guide expected. I don&#8217;t know where they went instead, but they certainly didn&#8217;t work.</p>
<p>Another complexity was the fact that ldap.conf needs to be in both /etc/ and /etc/ldap/ in order for both ldaptools and pam-ldap to be configured correctly. I think a problem with the compile options on one of those packages is a bug.</p>
<p>OK so, if you know much about how to debug pam-ldap, do post a comment. We&#8217;re stuck at the point where the clients are contacting the ldap server (can find it) but can&#8217;t authenticate to it. this I know from monitoring /var/log/auth.log.</p>
<p>Any other advice or good guides for client configuration or debugging would be very useful.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Sun Java System Directory Server 5.2 CLI tips: disabling a replication agreement]]></title>
<link>http://blog.udarnik.net/2009/10/06/sun-java-system-directory-server-5-2-cli-tips-disabling-a-replication-agreement/</link>
<pubDate>Tue, 06 Oct 2009 14:28:49 +0000</pubDate>
<dc:creator>N4A L</dc:creator>
<guid>http://blog.udarnik.net/2009/10/06/sun-java-system-directory-server-5-2-cli-tips-disabling-a-replication-agreement/</guid>
<description><![CDATA[In case you are to perform an upgrade, a useful thing to have is a CLI way to disable and enable a r]]></description>
<content:encoded><![CDATA[In case you are to perform an upgrade, a useful thing to have is a CLI way to disable and enable a r]]></content:encoded>
</item>
<item>
<title><![CDATA[13,800,000 entry Sun Directory Server 5.2 patch 6 Benchmark yields 17,000 searches per second]]></title>
<link>http://ff1959.wordpress.com/2009/10/05/13800000-entry-sun-directory-server-5-2-patch-6-benchmark-yields-17000-searches-per-second/</link>
<pubDate>Mon, 05 Oct 2009 23:43:43 +0000</pubDate>
<dc:creator>Terry Gardner</dc:creator>
<guid>http://ff1959.wordpress.com/2009/10/05/13800000-entry-sun-directory-server-5-2-patch-6-benchmark-yields-17000-searches-per-second/</guid>
<description><![CDATA[Introduction The Sun Directory Server provides the most scalable, high-performance LDAP data store f]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><h2>Introduction</h2>
<p>The <a href="http://www.sun.com/software/products/directory_srvr_ee/dir_srvr/index.xml">Sun Directory Server</a> provides the most scalable, high-performance <a href="http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol">LDAP</a> data store for identity information in the industry and serves as the foundation for the new generation of e-business applications and Web services.</p>
<p>Sun Directory Server provides a high-performance, scalable LDAP and <a href="http://en.wikipedia.org/wiki/Directory_Service_Markup_Language">DSML</a> directory services environment that supports multi-master relication for high-availability and redundancy.</p>
<p>The benchmark described in this post involved a requirement for a Consumer Directory Server for 13,800,000 user entries with Directory Server 5.2 patch 6 running on <a href="http://www.sun.com/servers/netra/x4250/">Sun Netra x4250</a> hardware and Solaris 10 update 7. The performance of Directory Server in a mixed LDAP operation environment is a mission-critical factor in proper authentication of user handsets in a large telecommunications company. The certification numbers to obtain were:</p>
<ul>
<li>8,000 searches per second with simultaneous updates</li>
<li>maximum 800 milliseconds for any single search</li>
<li>minimum 70% CPU utilization (usr+sys)</li>
</ul>
<p>Highlights of the benchmark:</p>
<ul>
<li>Sun Directory Server 5.2 patch 6 was installed on a single consumer node: a Sun Netra x4250, dual-<a href="http://www.intel.com/p/en_US/products/server/processor">CPU</a>, 8-core (2.13 Ghz), 64 GB RAM running Solaris 10 update 7 using internal disk drives</li>
<li>13,800,000 entries loaded into the Directory Server database in 2 hours</li>
<li>17,000 searches per second sustained over 8 hours with no single response time in excess of 2 milliseconds, an average latency of less than 2 milliseconds with no update (replication) traffic</li>
<li>11,000 searches per second sustained over 8 hours with no single response time in excess of 2 milliseconds, an average latency of than 2 milliseconds in the presence of update (replication) traffic</li>
<li><a href="http://www.slamd.com">SLAMD</a> was used to generate and report on load</li>
</ul>
<h2>Hardware Configuration</h2>
<h3>Consumer Server Node Hardware Specifications</h3>
<ul>
<li>2 quad-core 2.13Ghz <a href="http://www.intel.com/p/en_US/products/server/processor">Intel Xeon</a> processors, a total of 8 cores</li>
<li>64 GB RAM</li>
<li><a href="http://www.sun.com/software/solaris/">Solaris 10</a> update 7</li>
<li>gigabit ethernet</li>
</ul>
<h3>Consumer Server Node Storage Specifications</h3>
<ul>
<li><a href="http://opensolaris.org/os/community/zfs/">ZFS</a> used for Directory Server database files</li>
<li><a href="http://en.wikipedia.org/wiki/Unix_File_System">UFS</a> used for Directory Server logs</li>
<li>Seagate 10K 300GB SAS drives</li>
<li>See F<a href="http://www.thezonemanager.com/2009/03/filesystem-cache-optimization.html">ilesystem Cache Optimization Strategies</a> by Brad Diggs</li>
</ul>
<h3>Solaris Kernel Parameters (except ZFS)</h3>
<ul>
<li>autoup = 300</li>
<li>TCP/IP parameters as set by nddconfig stock distribution</li>
</ul>
<h3>ZFS Configuration</h3>
<ul>
<li>zfs:zfs_arc_max = 0xA80000000 (42 GB )</li>
<li>zfs:zfs_prefetch_disable = 1</li>
<li>zfs:zfs_vdev_cache_bshift = 13</li>
<li>zfs:zfs_cache_size = 0</li>
<li>8k record size</li>
</ul>
<h3>UFS Configuration</h3>
<ul>
<li>ufs:freebehind = 0</li>
<li>ufs:smallfile = 2147483647</li>
<li>mounted with forcedirectio</li>
</ul>
<h3>Test Client Hardware Specification</h3>
<ul>
<li>2 quad-core 2.13Ghz Intel Xeon processors, a total of 8 cores</li>
<li>64 GB RAM</li>
<li>Solaris 10 update 7</li>
<li>Java 1.6.0_16</li>
<li>gigabit ethernet</li>
</ul>
<h2>Directory Server and Database Configuration</h2>
<h3>Directory Server Software</h3>
<p>Sun Directory Server 5.2 patch 6 was used for this benchmark. All tuning parameters were left at default values with exceptions listed in the Tuning section below. The slab allocator libumem.so was used instead of the default single-threaded memory allocation library.</p>
<h3>Test Load Generation and Reporting</h3>
<p>SLAMD Version 2006 was used for LDAP load generation, data collection, and reporting. SLAMD is an open-source distributed load generator originally developed by Sun Microsystems. The principal developers of SLAMD are Neil A. Wilson and Terry J. Gardner. SLAMD consists of the following components:</p>
<ul>
<li>server software running in a Tomcat servlet container</li>
<li>Five (5) stand-alone Java programs (&#8220;SLAMD Clients&#8221;) for load generation</li>
<li>stand-alone Java programs (&#8220;SLAMD Resource Monitor Clients&#8221;) for collecting operating system metrics</li>
</ul>
<h2>Tuning</h2>
<h3>Sun Directory Server patch 6 Configuration</h3>
<ul>
<li>number of startup threads = 32</li>
<li>database cache size = 1 GB</li>
<li>entry cache size = 1 GB</li>
<li>import cache size = 2 GB</li>
<li>database mapping files in swapfs (/tmp) filesystem</li>
<li>audit logging activated (records all updates)</li>
<li>access log configured to log microsecond granularity</li>
<li>access, error, and audit file rotation at 20 MB</li>
</ul>
<p>Directory Server 5.2 patch 6 is a 32-bit process on Solaris Intel systems, therefore it is critical to keep the process size of DIrectory Server below 3.7 GB. To this end, the small database cache and entry cache sizes were used. The main caching entity was the ZFS cache, therefore the ZFS cache is primed at the beginning of test run, which prevents a test run from beginning with a &#8220;poisoned&#8221; cache. Observed process size after 8 hours of sustained load was 2503 GB. Note: the import cache is not used except during data bulk loads.</p>
<h2>Bulk Load of Data into Directory Server</h2>
<h3>Data Characteristics</h3>
<p>The data used for the database was taken from production customer Directory Servers, resulting in a very life-like benchmark. Each entry is of similar construction and is approximately 2302 bytes in size, including operational data and replication meta-data.</p>
<h3>Preparing for Bulk Load</h3>
<p>User data was extracted from customer production system backups and loaded into a Supplier (master) Directory Server. This Directory Server Supplier was used to generate replication traffic, but not otherwise part of the Benchmark. Once data was loaded into the Supplier it was tested using db_stat, then extracted using db2ldif -r to preserve replication data. The output of db2ldif -r was then imported into the Consumer Directory Server and replication between the Supplier and Consumer was enabled.</p>
<h3>Bulk Load Execution</h3>
<p>The user data, that is, the output of db2ldif -r, was loaded into the Consumer Directory Server using the ldif2db command. This process took approximately 2 hours.</p>
<p>After the database loaded into the Consumer Directory Server, the database, including the necessary index files was observed to approximately 15 GB.</p>
<h2>Benchmark Scenarios</h2>
<h3>Test Clients</h3>
<p>Five (5) SLAMD clients (stand-alone Java clients), with two (2) threads each generating search load from search filters constructed from actual customer data.</p>
<h3>Test Scenarios</h3>
<p>The Benchmark consisted of the following sequence, which was repeated in order for each benchmark run to ensure a level playing field for each sequence:</p>
<ul>
<li>The ZFS cache was primed with data from the database using the dd command</li>
</ul>
<ul>
<li>a database cache priming job consisting of a 	1200 second (20 minute) SLAMD job comprised of a series of LDAP 	searches using search filters derived from customer data</li>
<li>a 5 minute null job – no activity, allows 	Directory Server to quiesce</li>
<li>two simultaneous jobs: 1) a job generating ADDs, MODs, and DELs in the precise mixture derived from customer provided access logs from production systems. This job is schedule for 8 hours duration, but in reality takes longer because ADDed entries are removed at job completion. 2) a job executing searches using search filters derived from customer provided data.</li>
</ul>
<h2>Benchmark Results</h2>
<p>The Consumer Directory Server sustained 11,000 searches per second and replication (ADD, MOD, DEL) simultaneously over an 8 hour period.</p>
<h2>Conclusion</h2>
<p>The certification search throughput was exceeded by over 3,000 searches per second, and response times were less than 1/800 of maximum tolerable response times.</p>
<p>The combination of Sun Directory Server 5.2 patch 6, Solaris 10 update 7, dual-cpu 8-core Sun x4250, and libumem.so makes a very fast, memory efficient Directory Server platform. The customer will deploy 8 identically configured servers, resulting in a maximum throughput of 88,000 searches per second simultaneously with updates.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Travel Day, 02-Oct-2009]]></title>
<link>http://ff1959.wordpress.com/2009/10/03/travel-day-02-oct-2009/</link>
<pubDate>Sat, 03 Oct 2009 14:49:38 +0000</pubDate>
<dc:creator>Terry Gardner</dc:creator>
<guid>http://ff1959.wordpress.com/2009/10/03/travel-day-02-oct-2009/</guid>
<description><![CDATA[Travel Day Today is travel day, that is, the day I must interrupt my work and travel home. In this i]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><h3>Travel Day</h3>
<p>Today is travel day, that is, the day I must interrupt my work and travel home. In this instance, Newark&#8217;s <a href="http://www.panynj.gov/CommutingTravel/airports/html/newarkliberty.html">Liberty Airport</a> to the <a href="http://www.atlanta-airport.com/">Delta Fortress.</a> <a href="http://www.delta.com">Delta Air Lines</a> will be operating the flight with a <a href="http://www.boeing.com/commercial/737family/">B73</a>. After an uneventful flight &#8211; which is just like I like my flights &#8211; arrived early in Atlanta.</p>
<p style="text-align:center;">A <a href="http://www.boeing.com/commercial/757family/">B75</a> attended by support craft and food tenders at the Delta Fortress:</p>
<div style="text-align:center;"></div>
<div style="text-align:center;"><img src="http://ff1959.files.wordpress.com/2009/10/200910020733.jpg?w=480&#038;h=360" alt="The Delta Fortress" width="480" height="360" /></div>
<h3 style="text-align:center;">DS52p6 Iterations on x4600</h3>
<p>Ran an <a href="http://www.slamd.com">SLAMD</a> optimizing job using libmtmalloc on the 4600 with 8 cores, 32GB RAM, database on ZFS, achieved greater than 20,000 searches per second, using Sun Directory Server 5.2 p6. libmtmalloc is a multi-threaded implementation of the standard memory allocation library, see also malloc(), calloc(), free().</p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
