Populate vjud with email address

I'm working on a way to allow the user the ability to reset their own ejabberd password through a web site. I was thinking of using the user's registered email address as a means of authentication. The problem is that unless each person provides their email address in the jud, it's not possible. My hope would be to use the ejabberdctl script and have it populate the email address during account creation. Something like... ejabberdctl ejabberd@localhost register ssmith localhost mypassword sam.smith@company.com

Just ran into another snag... It appears that you can't use ejabberdctl to reset a registered user's password. I just tried it and the script complained that the user is already registered. Is there a way to programmatically reset a user's password? Looks like it could be done with a little tweaking of ejabberdctl.

Reset user password

OK. I figured out how to reset user passwords by modifying the ejabberdctl behavior. Here is what I did:

Edited ejabberd_ctl.erl and inserted the following right before the line reading: process(Node, ["register", User, Server, Password]) -> (line 86)

process(Node, ["reset", User, Server, Password]) ->
    case rpc:call(Node, ejabberd_auth, set_password, [User, Server, Password]) of
        {atomic, ok} ->
        {error, Reason} ->
            io:format("Can't locate user ~p at node ~p: ~p~n",
                      [User ++ "@" ++ Server, Node, Reason]),
        {badrpc, Reason} ->
            io:format("Can't locate user ~p at node ~p: ~p~n",
                      [User ++ "@" ++ Server, Node, Reason]),

Next, I added the following right before the line reading: " register user server password\tregister a user~n" (line 261)

      "  reset user server password\treset user's password~n"

Recompiled and it works fine.

Now I just need to be able to populate the email address field in the database upon registration and I'll be set.

Modify vcard table via command line

I'm still trying to populate the vjud automatically when a user signs up (registers) their account. I've looked at the code and have to admit that the mnesia commands have me stumped. Probably simple syntax errors.

Anyhow, is there a way to populate the vcard table on the command line? Looks like the mod_vcard may be a possibility, but I can't tell if it is able accept arguments. At a minimum, I'd like to be able to write to the fn, family, and email fields. Any help is appreciated.

I use this script for

I use this script for modifying users' vCard data. You could modify it to suit your requirements.

Corrupting the record??


Thanks for providing the script. I modified it and got it to run. It returns bbrazell@jabbertest.wireless.attws.com: OK. The problem is that I think it's corrupting the record since I'm unable to view it after running the script. Here is the command I entered:

./vcard.tcl bbrazell Bill Brazell

Does that look right? Any ideas why the record is getting corrupted?

You wrote: I modified it and

You wrote: I modified it and got it to run. How then can I have an idea about its behavior?

Sorry. More details...

Prior to running the script, I verified that I'm able to view/modify the vcard from a Jabber client.

I modified the following lines in the script:

set username [lindex $argv 0]
set servername "jabbertest.wireless.attws.com"
set given [lindex $argv 1]
set family [lindex $argv 2]
set orgname "Cingular"

I also changed these lines, changing from -sname to -name and giving it the FQDN of the ejabberd host. If I leave it set to $hostname, it reports the following error: =ERROR REPORT==== 18-Jul-2005::09:47:18 ===
** System running to use fully qualified hostnames **
** Hostname localhost is illegal **

set res [exec /usr/local/bin/erl -name vcards << \
"rpc:call('ejabberd@jabbertest.wireless.attws.com', mod_vcard, process_sm_iq, \[$jid, $jid, $query\])."]

I then run the script giving it the following arguments:

./vcard.tcl bbrazell Bill Brazell

Script returns: bbrazell@jabbertest.wireless.attws.com: OK

I then try to view the vcard for the modified record and the client is unable to retrieve it. Does that help? I can provide more information upon request. Thanks

You are right. There's a bug

You are right. There's a bug in the script. I've put corrected version under the same link as above.

Getting close, but need some assistance

I can't get the script to change the value of the email address field. Here is what I've tried.

I modified the script to accept another argument on the command line : set email [lindex $argv 3]

I then changed the following section as follows:

set vCard [xmlelement vCard \
-attr {xmlns vcard-temp} \
-subtag [xmlelement FN -cdata "$given $family"] \
-subtag [xmlelement N \
-subtag [xmlelement FAMILY -cdata $family] \
-subtag [xmlelement GIVEN -cdata $given]] \
-subtag [xmlelement EMAIL \
-subtag [xmlelement USERID -cdata $email]]]

When I run the script with these values:
./vcard.tcl bbrazell Bill Brazell bill@home.com, I can see the $query value equal to:

{iq, "", set, "", "en", {xmlelement, "vCard", [{"xmlns", "vcard-temp"}], [{xmlelement, "FN", [], [{xmlcdata, "Bill Brazell"}]}, {xmlelement, "N", [], [{xmlelement, "FAMILY", [], [{xmlcdata, "Brazell"}]}, {xmlelement, "GIVEN", [], [{xmlcdata, "Bill"}]}]}, {xmlelement, "EMAIL", [], [{xmlelement, "USERID", [], [{xmlcdata, "bill@home.com"}]}]}]}}

I know it must be something with the way I'm specifying the EMAIL element. If I change the reference to NICKNAME, it works fine. Here is a line from mod_vcard.erl that may lend a clue:

EMail1 = xml:get_path_s(VCARD, [{elem, "EMAIL"}, {elem, "USERID"},cdata]),

Any ideas how to get this to work?

I think I got it

Changed the reference to the EMAIL element like this and it works:

set vCard [xmlelement vCard \
-attr {xmlns vcard-temp} \
-subtag [xmlelement FN -cdata "$given $family"] \
-subtag [xmlelement N \
-subtag [xmlelement FAMILY -cdata $family] \
-subtag [xmlelement GIVEN -cdata $given]] \
-subtag [xmlelement EMAIL \
-subtag [xmlelement INTERNET] \
-subtag [xmlelement PREF] \
-subtag [xmlelement USERID -cdata $email]]]

How do I use the Teo TCL Script

I am new to ERLang. How do I use the TCL script? I am trying to populate all my users v_card info.

Some simple instructions would be greatly appreciated

Brian C

Syndicate content