Suppose you are developing an ASP.Net application in a primarily open source/linux/MySQL environment, you might run into some odd issues with interoperability. A top-secret project of mine (that I intend to open source once I've got a handle on which license is appropriate) needs minimally to work with MySQL and OpenLDAP. MySQL is no problem as the builds of the MySQL connector for ADO.NET 2 have been very solid, though it does give me odd "warnings" about unnecessary conversions when using reader.GetInt32(0) and such.
OpenLDAP, well, it seems decent enough for our purposes but there are some stumbling blocks. The ActiveDirectory Membership and Role providers that come with .NET 2.0 will not work for you. Oh, I know the connection string misleadingly takes LDAP://ou=blah blah;cn=blahblah;dnblahblah syntax but the implementation uses various AD specific calls so you have to home roll your own. There are two decent solutions here: you can use the classes in System.DirectoryServices to implement the various searches. I was concerned at first that this would not work under Mono, which is one thing I'm shooting for, but I should have done my homework as the Mono project does have a System.DirectoryServices implementation. I also found some old Novell C# code hanging around that gives you some LDAP specific abstractions. Either way, you can roll your own Role and Membership providers that talk to OpenLDAP. OpenLDAP does not support the memberOf syntax, apparently, which is annoying. You can search under the ou=Groups for objects of type posixGroup and get the memberUid attribute to sort of go at it backwards to implement the GetUsersForRole functionality for your Role provider:
public List<string> GetUsersForRoleName(string roleName)
{
List<string> userNames = new List<string>();
string searchPattern = "(&(objectclass=posixGroup)(cn={0}))";
string searchStr = string.Format(searchPattern, roleName);
LdapSearchResults sr = _ldapCon.Search("ou=Groups," + _rootDn, LdapConnection.SCOPE_SUB, searchStr, null, false);
while (sr.hasMore())
{
LdapEntry entry = sr.next();
LdapAttribute att = entry.getAttribute("memberUid");
string[] names = att.StringValueArray;
for (int i = 0; i < names.Length; ++i)
{
userNames.Add(names[i]);
}
}
return userNames;
}
I should surely post this project once it's mostly done, as it's potentially quite useful.