[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Text files or text on OpenLdap



Sergio Cioban Filho wrote:
> 
> How I do to store text files or text on OpenLdap?
> I'm trying with octetString, but the line termination do not respected.
> 
> I want store openssh Keys (Public and Private) on OpenLdap.

Which format do you use? The files as found in $HOME/.ssh? The file
id_dsa is in ASCII-armored base64-representation. Do you want that?

I vaguely remember that someone already defined a LDAP schema for SSH
keys. You might wanna dig for it with your favourite search engine.

Provided that your LDAP client preserves the data and sends it to the
server as-is using OctetString syntax should be safe. I suspect that you
have presentation issues with the LDAP client you're using. E.g. when a
web-based LDAP client sends the attribute value simply as HTML text to
the browser the line-endings are simply ignored by the browser.

In my web2ldap you can easily define plugin-classes for
displaying/editing such an attribute value as multi-line text attribute
value.

Displaying PGP keys with the online demo (see accompanying plug-in
module/class below, lines are wrapped):

http://demo.web2ldap.de:1760/web2ldap?ldap://keyserver.pgp.com/pgpCertID=7D53CAC1430BFB45,o=searchable%20pgp%20keys??base

I use exactly this mechanism for XML data found in some IdM products etc.

Ciao, Michael.

--------------------------------- snip ---------------------------------

"""
web2ldap plugin classes for PGP key server

$Id: pgpkeysrv.py,v 1.2 2008/09/24 08:20:27 michael Exp $
"""

import re
from w2lapp.core import utf2display
from w2lapp.schema.syntaxes import Binary,MultilineText,syntax_registry


class PgpKey(MultilineText):
  oid = 'PgpKey-oid'
  desc = 'PGP key'
  reObj=re.compile('^-----BEGIN PGP PUBLIC KEY
BLOCK-----[a-zA-Z0-9+/]-----END PGP PUBLIC KEY BLOCK-----$',re.S+re.M)
  lineSep = '\n'
  mimeType = 'application/pgp-keys'
  cols = 64

  def displayValue(self,valueindex=0,commandbutton=0):
    lines = [
      utf2display(self._form.accept_charset,l)
      for l in self._split_lines(self.attrValue)
    ]
    return '<code>%s</code>' % '<br>'.join(lines)


syntax_registry.registerAttrType(
  PgpKey.oid,[
    '1.3.6.1.4.1.3401.8.2.11', # pgpKey
  ]
)


# Register all syntax classes in this module
for symbol_name in dir():
  syntax_registry.registerSyntaxClass(eval(symbol_name))