|
Tuesday, July 13, 2004 |
Major gift supports OA at Harvard. Harvard has received a $5 million gift to support its Open Collections Program,
whose mission is to digitize and provide open access to material from
the Harvard libraries. The donors are Lisbet Rausing and Peter Baldwin,
both historians and both Harvard alums. Quoting Harvard president
Lawrence Summers: "Intellectually curious people from every corner of
the globe will have free access to such information, for the benefit of
their studies, their interests, and their work." For more details, see
the press release. [Open Access News]
10:00:00 AM Google It!.
|
|
Geolocation: Don't Fence Web In.
As geolocation -- technology that can track the location of computers
surfing the Internet -- improves, corporations and governments are
increasingly able to limit what people can view on the Web. [Wired News]
9:27:38 AM Google It!.
|
|
Gush 1.1 RC 1 and Linux Debut.
We are happy to announce our newly added support for Linux! Gush now
leaves no OS behind. Release candidate 1 sports a few new features,
interface improvements, as well as serious improvements under the hood.
We've worked hard to improve Gush's memory usage and stability and to
provide new additions like the new photoblog friendly image browser.
Please refer to the changelog for details. This release is for all platforms and users can now expect synchronized releases from here on out.
As always, get help or leave some suggestions by messaging our support account: bugreports@2entwine.net By Wes. [Gush Blog]
9:22:51 AM Google It!.
|
|
Scripting LDAP with Jython -- Queries. I've been playing with LDAP
directories from Jython and thought I should share a couple of useful
examples of what you can do. The first of these is a quick barebones
query example. Enjoy.
# Jython LDAP Example
from javax.naming import *
from java.util import *
from javax.naming.directory import *
# Credentials to access LDAP
user = "cn=master"
passwd = "password"
# Query starting point and query target
search_start = "ou=People,dc=Company,dc=com"
search_target = "uid=aUserID"
# Setup LDAP Context Options
settings = Hashtable()
settings.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory")
settings.put(Context.PROVIDER_URL, "ldap://localhost:389")
settings.put(Context.SECURITY_PRINCIPAL, user)
settings.put(Context.SECURITY_CREDENTIALS, passwd)
# Connect to LDAP Server
ctx = InitialDirContext(settings)
srch = SearchControls()
srch.setSearchScope(SearchControls.SUBTREE_SCOPE)
# Execute LDAP Search
results = ctx.search(search_start, search_target, srch )
#Display Search`
for result in results:
attributes = result.getAttributes()
names = []
for atr in attributes.getIDs():
names.append(str(atr))
for name in names:
print attributes.get(name)
[All things Jythonic]
12:03:30 AM Google It!.
|
|
Scripting LDAP with Jython -- Load Java Objects from LDAP. A common
way to store user preference data for applications is to store them in
LDAP as a serialized Java Hastable object. The application then reads
that back from ldap on startup using the authenticated userid as the
key. Its a convenient way to store application settings. But what if
you need to adjust or migrate settings from one place to the other?
Here is an approach to reading that data out using Jython. Look for a
future post about how to save it back using the context's bind method
...
# Jython LDAP - Retrieve Stored Object from LDAP Example
from javax.naming import *
from java.util import *
from javax.naming.directory import *
# Credentials to access LDAP
user = "cn=master"
passwd = "password"
# Setup LDAP Context Options
settings = Hashtable()
settings.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory")
settings.put(Context.PROVIDER_URL, "ldap://localhost:389")
settings.put(Context.SECURITY_PRINCIPAL, user)
settings.put(Context.SECURITY_CREDENTIALS, passwd)
# Connect to LDAP Server
ctx = InitialDirContext(settings)
# load the java Hashtable out of the ldap server
prefs = ctx.lookup("cn=ccm_root,ou=Preferences,dc=Company,dc=com")
for pref in prefs.keys():
print "PREF: %s\n VALUE: %s " % (pref, prefs[pref])
[All things Jythonic]
12:03:08 AM Google It!.
|
|
Scripting LDAP with Jython -- Store Java Objects in LDAP. This is
the complement to the earlier example that read a java Hastable out of
an ldap directory entry. Here is how you get the data in there to begin
with.
# Jython LDAP - Store Java Hashtable into LDAP Example
from javax.naming import *
from java.util import *
from javax.naming.directory import *
# Credentials to access LDAP
user = "cn=master"
passwd = "password"
# Setup LDAP Context Options
settings = Hashtable()
settings.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory")
settings.put(Context.PROVIDER_URL, "ldap://localhost:389")
settings.put(Context.SECURITY_PRINCIPAL, user)
settings.put(Context.SECURITY_CREDENTIALS, passwd)
# Connect to LDAP Server
ctx = InitialDirContext(settings)
# build Hastable we want to store
userPrefs = Hashtable()
userPrefs.put("Server", "Someserver.com")
userPrefs.put("Color", "Red")
userPrefs.put("Wine", "Cabernet")
userPrefs.put("Year", "1994")
ctx.bind("cn=test_user,ou=Preferences,dc=Company,dc=com", userPrefs)
#done
If the entry already exists you need to use the context's rebind method like this:
ctx.rebind("cn=test_user,ou=Preferences,dc=Company,dc=com", userPrefs)
[All things Jythonic]
12:02:18 AM Google It!.
|
|
© Copyright 2004 Bruce Landon.
|