Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change user permissions on a document. 1

Status
Not open for further replies.

DilipN

Programmer
Jan 28, 2005
17
US
Dear Friends ,

I would like to assign specific permissions on a document to specific users using JAVA API's.

I have a document "mytest.doc" i want to make this document invisible from all the users except 2 other users.

I tried to revoke all the permissions there are no errors thrown from the java code, but it does not revoke the permission.

Also could someone please tell me how to assing permissions to a specific user.

below is my code please tell me where am i going wrong.

public void changePermissions(int iDocID)
{
LAPI_DOCUMENTS doc;
LLValue entInfo = (new LLValue()).setAssocNotSet();
doc = new LAPI_DOCUMENTS(llSession);
if(0 != doc.AccessEnterpriseWS(entInfo) )
{
System.out.println("AccessEnterpriseWS Failed.");
return ;
}
int volumeID = entInfo.toInteger("VolumeID");
LLValue objInfo = new LLValue();
doc.GetObjectInfo(volumeID , iDocID,objInfo);

System.out.println(" Status .... " +objInfo.toString("STATUS"));

objInfo = new LLValue();

doc.GetObjectRights(volumeID , iDocID,objInfo);
doc.SetObjectRight(volumeID , iDocID,LAPI_DOCUMENTS.RIGHT_DELETE,LAPI_DOCUMENTS.RIGHT_GROUP,LAPI_DOCUMENTS.PERM_FULL,0);
System.out.println(" Error Message After Removing Groups Permissions.. "+ llSession.getErrMsg());
System.out.println(" Status Message .. "+ llSession.getStatusMessage());

doc.SetObjectRight(volumeID , iDocID,LAPI_DOCUMENTS.RIGHT_DELETE,LAPI_DOCUMENTS.RIGHT_OWNER,LAPI_DOCUMENTS.PERM_FULL,0);
System.out.println(" Error Message After Removing Owners Permissions .. "+ llSession.getErrMsg());
System.out.println(" Status Message .. "+ llSession.getStatusMessage());

doc.SetObjectRight(volumeID , iDocID,LAPI_DOCUMENTS.RIGHT_DELETE,LAPI_DOCUMENTS.RIGHT_SYSTEM,LAPI_DOCUMENTS.PERM_FULL,0);
System.out.println(" Error Message After Removing System Permissions.. "+ llSession.getErrMsg());
System.out.println(" Status Message .. "+ llSession.getStatusMessage());
}
 
I think like all starting LAPI programmers you are having a tough time understanding livelink.Your codeing is extremely good and structured but I will try to explain a few anomalies .I will also send you a simple java file that will help you understand the data structures to a good extent.
Code:
 doc.SetObjectRight(volumeID , iDocID,LAPI_DOCUMENTS.RIGHT_DELETE,LAPI_DOCUMENTS.RIGHT_OWNER,LAPI_DOCUMENTS.PERM_FULL,0);
should read something like
Code:
doc.SetObjectRight(volumeid,dataid,doc.RIGHT_UPDATE,userid,doc.PERM_SEE|doc.PERM_SEECONTENTS,0);
Your code was doing a delete of the acl entry for the owner for that object.The code that I have shown you gives 'userid' a group or user already permitted into the object SEE and SEE CONTENTS.If you wanted to add a group or userid into any livelink object then you would use RIGHT_ADD.If you wanted to take out a groupid form an object then you would use RIGHT_DELETE. Every livelink object comes pre-configured for user,group,public and system to which you start adding more and more groups and userids.I hope this makes sense.There is a lot of BITMASK aritmetic in livelink but I would advise you to see the permissions of the object by going to the GUI and turning ona and off bitmaks there.In simple terms this is what happens
Code:
Object gets created
Object permissions for Owner,Group,World,System established in dtree.The left top part of the permissions page GUI
The permission levels which are a set of bitmasks also
get established.For eg if you see Owner having no perms then you will see '128' as the value
You start adding a Group or user-Rightid gets created in dtreeacl now with bitmasking


Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Thank you very much for your response and time.
I am really thankfull that you are responding everyones queries.

What i want to do is revoke everybodys permission and just assing it to 2 people, creator and the Approver. and once the approver approves the document then i need to publish it to all the users. That is the reason i was tring to revoke everybodys permission.

I did try doc.SetObjectRight(volumeid,dataid,doc.RIGHT_UPDATE,userid,doc.PERM_SEE|doc.PERM_SEECONTENTS,0);

It still doesn't do anything. i did check the dTreeACL table in my database it does not show any changes. even though my code statements does not return any error codes.

But if I try to assign/Revoke permissions through Livelink Interface I do see all the Changes in DTreeACL table.

So i tried to debug through Livelink Builder and i checked the oScripts through Livelink Builder and this is what i see in the scripts.

function Assoc NodeRightDelete( DAPINode node, Integer rightID )
//Delete an acl permission of a node by specifying right id
Assoc rtnval
rtnval.OK = FALSE
rtnval.ErrMsg = [LLAPI_LLNodeErr.ThisNodeTypeIsNotSupported]
return( rtnval )
end

I have livelink 9.1 with SP2. Does that mean that there is something wrong in my livelink version.

Thank you.

Dilip Nimse.
 
Sorry I forgot to add one more thing in my previous message
even scripts NodeRightUpdate & NodeRightAdd have the same type of logic in it.
 
Who is the user performing the LAPI transaction.Only if users has perms will your lapi code work.REun it as the Admin user and see.

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
While performing these LAPI Transaction, Yes I am using Admin Users credentials and session.

Thank You ,

Dilip Nimse.
 
If it is in a workflow attachment area then the workflow volumeid is different from the enterprise volumeid.Did you check those.For checking you can do this.If 1234 is the nodeid of your document in a workflow volume run sqlquery
select * from dtree where dataid=1234.Ownerid something negative is your volumeid in this case.Then only you can do nodeupaatae stuff.Try also a regular document residing in the enterprise workspace.other than that I can't think of anything else.Did the java file I sent you help any better ?

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Thank You very much for the reply.

I did try to change permissions of a document from the root folder but it still doesn't change the permissions. I even tried the java code that you sent. I have a feeling that there is something wrong in my livelink.because I sent the code to one of my friends who has also started working in Livelink.
It did work for him, but not for me. that is how i came to conclusion that there is something wrong with my livelink.
I am in process of upgrading the livelink.

Thank you very very much for your help.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top