Raffaello Pelagalli <raffaello(a)xwiki.com> writes:
<PraveenVenkata.Koduganty(a)cognizant.com>
writes:
Is there any way I can import users into XWiki
from an LDAP source. I am
currently authenticating users against LDAP, but am unable to create groups, or
set specific rights to these LDAP users.
Thanks and Regards
Praveen Koduganty.
Hi,
I think you are looking for a script like this one :
----------------------START---------------------
<%
if (request.get("go") == "1")
{
results = xwiki.ldap.search("objectclass=*")
for (res in results.values())
{
if (res.get("cn") == null)
continue;
username = res.get("cn").toLowerCase()
username = context.getContext().getWiki().convertUsername(username,
context.getContext())
def created = "created"
udoc = xwiki.getDocument("XWiki." + username)
if (!udoc.isNew())
{
udoc.delete()
created = "updated"
}
xwiki.ldap.createUserFromLDAP(username, res.get("cn"), null, null)
print("*" + created + "*" + " ")
print ("{pre}" + res.get("cn") + "{/pre} [XWiki." +
username + "]<br/>")
}
}
%>
#if(!$request.get("go") || $request.get("go") != "1")
[Import and/or Update Users>$doc.name?go=1]
#end
----------------------END-----------------------
Perhaps you will need to modify it to fit your needs.
You should take a look at the ldap plugin API (exactly this file :
http://svnmirror.xwiki.org/svn/mirror/xwiki/xwiki-platform/core/trunk/xwiki…)
Best regards,
Due to a bug in the LDAPPlugin, the line
xwiki.ldap.createUserFromLDAP(username, res.get("cn"), null, null)
has to be replaced by :
xwiki.ldap.getPlugin().createUserFromLDAP(username, res.get("cn"), null, null,
context.getContext())
Or the script will never finish.
Best regards,
--
Raffaello Pelagalli
XPertNet -
XWiki.com