Raff,
That looks like a very interesting code snippet to put in the code
zone (as a Code Snippet)!
-Vincent
On Sep 14, 2007, at 10:28 AM, Raffaello Pelagalli wrote:
<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-core/src/main/java/com/xpn/xwiki/plugin/ldap/
LDAPPluginApi.java)
Best regards,
--
Raffaello Pelagalli
XPertNet -
XWiki.com
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users