How to Programmatically CREATE user in 'names.nsf'?

palsen
palsen used Ask the Experts™
on
Hello Experts,

I have web based application with the list of users. The Requirement is to register all the user from my application to Sametime server and display the sametime client connect applet. This applet has the facility to call for meeting, chat and stuffs like that. I am able achieve this using the SameTime Java Tool Kit. But i am not able to find a way to register the user from my application to SameTime Server(Programmatically).

I would be eternally grateful if someone help's me out here.

Thanks in Advance!

Sen.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Sametime Server looks at your Domino Directory (Server Address book) for the list of users. You don't have to add them seperately. When they login using their internet id and password listed in person document for each person they will have rights to access the sametime server.

There are 4 different ways the user can be registered

Using LDAP
Domino Administrator client
Sametime Administration Tool
Sametime self registration

If you need more help on how the sametime is setup take a look at this redbook (Chapter 4)
http://www.redbooks.ibm.com/redbooks/pdfs/sg246587.pdf

http://publib-b.boulder.ibm.com/Redbooks.nsf/9445fa5b416f6e32852569ae006bb65f/fdd3fc695c5c49f085256c4600601864?OpenDocument

~Hemanth

Bozzie4IT Architect
Commented:
And of course, you can programmatically add a user to the directory.

You can use the Notesregistration class (I don't think you can do it in Java, because that class doesn't exist in java, I think), to really create a Notes user, with a Notes id, but for Sametime, that's not really necessary.

You'll need to create Person documents in the names.nsf, and (maybe) put those people into groups so you can organize them.
That's not so hard, and maybe more importantly for you, it can be done in Java.



Check the sandbox on Notes.net (well, ldd it's called now) for a webbased registration application.
http://www-10.lotus.com/ldd/sandbox.nsf/Search?SearchView&Query=registration&SearchOrder=1&SearchMax=1000&SearchWV=FALSE&SearchFuzzy=FALSE&Start=1&Count=10

cheers,

Tom

Commented:
Hemantha's answer assumes that the users already have a Domino user entry.

Bozzie's answer assumes that you want the user fully registered for Notes client access.

I believe you want something "in between."  No Notes client access, but do allow the user to be created as a new entry in the Domino server with web/SameTime access.


The following subroutine will do it, you just need to provisde the appropriate parameters.  The directory requires the following fields:
1) FullName
2) LastName

To log on, it also needs:
3) HTTPPassword

And you may also want:
4) e-Mail

For 1 and 2, I am going to use the same value -- a "user ID," which you pass in as the second parameter.  It doesnt mater whether it really is a full name or a last name, Notes just wants a value there, which will be used as user ID.

I won't do 4 here, let me know if you need it.

So, here's my parameter list:

1) name of Domino server where the Directory will be used; this shoudl be the name of teh Domino server hosting SameTime
2) User name (used for 1 and 2)
3) Password

The retrun value will be a null string (success) or a string containing an erro message.

Function Reg ( server as string, userID as string , password as string) as string
on error goto die

if server = "" or userID = "" or password = "" then
Reg = "Missing required paraneter"
exit function
endif

Dim db as new notesDatabase ( server , "names.nsf")
dim view as notesView
set view = db.getView("($Users)")
dim doc as notesDocument
set doc = view.getDocumentByKey ( userID , true )
if not (doc s nothing) then
Reg = "User alreadt exists"
exit function
end if

set doc = db.createDocument
doc.form = "Person"
doc.Type = "Person"
doc.Fullname = userID
doc.LastName = userID
doc.HTTPPassword = password
Dim passHash as variant
passHash = Evaluate("FIELD HTTPPAssword := @Password(HTTPPassword);Qwaletee",doc)
doc.save true,true
view.refresh
exit function

die:
reg = "Error " & err & " on line " & erl & ": " &error
exit function

End Function
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Author

Commented:
Thanks much big guys!

Let me elaborate my requirements little better.

Existing Environment
--------------------------

* We have web based application - It's not Domino based. It's J2EE based and it uses the XML native database (XIndice) for data storage.

* We do have Sametime & Domino server - Which is used for QuickPlace, Sametime connect and Mail server.

New Requirement
----------------------

* I need to create a sametime client (One Similar to SameTime Connect Client) using java toolkit. Which will be integrated to my web based application - I am able to achieve this.

* I need to take the list of user from my web based application(Stored in the XML database) and add them to domino directory. I have to do this programmatically form my web based application deployed in tomcat - I am actually stuck here. Can you guys help me out.

Thanks again for your support

Sen.

Commented:
You can adapt the code I have above to the Notes API for Java, which can be remoted via IIOP.

Commented:
Alternatively, the code above can be adapted into an agent, which runs onyour Domino server.  Your Java code could call the agent via HTTP. Example below:


Sub Initialize 'main agent entry point

Dim s as new notesSession
Dim doc as notesDocument
Set doc = s.documentContext
Dim QS as string
QS = doc.QUERY_STRING(0)
userID = getParam(QS,"userID")
password = getParam(QS,"password")
CONST LOCAL_SERVER = ""
Print Reg(LOCAL_SERVER,userID,password)

End Sub 'Initialize

Function getParam ( byval source as string , byval key as string )
source = source & "&"
key = key & "="
Dim keySize as integer, keyStart as integer, paramStart as integer, beyondParam as integer, paramSize as integer
keySize = len(key)
keyStart = instr(ucase(source),ucase(key))
if keyStart = 0 then  Exit Function
paramStart = keyStart + keySize
beyondParam = instr(paramStart,QS,"&") - 1
if beyondParam <= paramStart then Exit Function
paramSize = beyondParam-paramStart
getParam = Mid(QS,paramStart,paramSize)
End Function

'include Function Reg from earlier comment

Commented:
Adapting Reg function to a remote Java call...

This exampel from Domino developer help shows how to access Domino calls via IIOP:

import lotus.domino.*;
public class platform6 implements Runnable
{
  String host=null, user="", pwd="";
  public static void main(String argv[])
    {
      if(argv.length<1)
      {
        System.out.println(
           "Need to supply Domino server name");
        return;
      }
      platform6 t = new platform6(argv);
      Thread nt = new Thread((Runnable)t);
      nt.start();
    }
  public platform6(String argv[])
  {
    host = argv[0];
    if(argv.length >= 2) user = argv[1];
    if(argv.length >= 3) pwd = argv[2];
  }
  public void run()
    {
    try
      {
        Session s = NotesFactory.createSession(
                    host, user, pwd);
        String p = s.getPlatform();
        System.out.println("Platform = " + p);
      }
    catch (Exception e)
      {
        e.printStackTrace();
      }
    }
}

Commented:
The "heart" of teh syste after all the setup in the previous example is the following two lines:


       String p = s.getPlatform();
       System.out.println("Platform = " + p);
     
We would replace it with code to do the registraion. The classes and methods you need to know about are as follows:

LotusScript example from reg / Java equivalent
db as notesDatabase / lotus.domino.Database
db as New notesDatabase / lotus.domino.Session.getDatabase
view as notesView / lotus.domino.View
db.getView / lotus.domino.Database.getView
doc as notesDocument / lotus.domino.Document
view.getDocumentByKey / lotus.domino.getDocumentByKey ( Object key , boolean exact ) -- use a String key, exact should be true
doc is nothing / doc != NULL
db.createDocument / lotus.domino.Database.createDocument
doc.form = "Person" / lotus.domino.Document.replaceItemValue ( String itemname , Object value ) where itemname is "Form" and value is the string "Person"
doc.Fullname = userID / lotus.domino.Document.replaceItemValue ( String itemname , Object value ) where itemname is "FullName" and value is the string conating the user ID
Evaluate("FIELD HTTPPAssword := @Password(HTTPPassword);Qwaletee",doc) / lotus.domino.Session.evaluate ( String formula , Document doc )
doc.save true,true / lotus.domno.DOcument.save
view.refresh / lotus.domino.View.refresh

Commented:
Hemantha and Bozzie are great, and they supplied good answers to a more general question.  I believe I was the only one to address the true question originally -- how to register a new user for web-only access.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial