Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Content Management (Extended ECM)
API, SDK, REST and Web Services
I not so bright on bitwise arithmatic...
David_Henderson
I'm trying to use the LAPI to modify UserPrivileges attribute.I've created an app that synca our company ldap system with LiveLink.When a user is removed from our ldap system, I don't want to delete that user from LL, I just want to remove their login privilege (leaving any other privilege they may have been granted in tact).In java something like:currentPrivs -= LAPI_USERS.PRIV_LOGINseems to be working ok. Am I missing some major "gotcha" having to do with bitwise arithmatic?THEN, let's say one of these users shows back up in the ldap system (the reason behind this is contractors that enter and leave our ldap system as they move from group to group, project to project). Now I'd like to re-grant the login privilege to whatever privilege set they may have had.So I've tried something like:// Remember users's "original" priviledgesint origPrivileges getUserAttr.toInteger("UserPrivileges");// Add "login" right to user priviledges to compareprivileges = origPrivileges + LAPI_USERS.PRIV_LOGIN;if (privileges != origPrivileges){ userAttr.add("UserPrivileges", privileges); updateMsg += " User was lacking Login Privilege, privilege restored.";}But this is being triggered everytime because of the "int" nature. privilege is always just origPrivileges + 1.So then, HOW do I "add" or "subtract" a single privilege to/from an existing privilege set using bitwise arthmatic?Any help would be GREAT!Thanks,-Zac Morris
Find more posts tagged with
Comments
David_Henderson
Ok, I think I found something that works:Instead of what I posted in my previous post, this seems to work correctly to "confirm" if a user has "Login" priviledges.// Remember users's "original" priviledgesint origPrivileges = getUserAttr.toInteger("UserPrivileges");// remove "login" right from user priviledges to compareprivileges = origPrivileges;privileges &= ~LAPI_USERS.PRIV_LOGIN;if (privileges == origPrivileges){ privileges |= LAPI_USERS.PRIV_LOGIN; userAttr.add("UserPrivileges", privileges);}The line: privileges &= ~LAPI_USERS.PRIV_LOGIN; removes login rightsThe line: privileges |= LAPI_USERS.PRIV_LOGIN; grants login rightsWhat I don't fully understand is that:privileges &= ~LAPI_USERS.PRIV_LOGIN; doesn't change the value of privileges IF the users doesn't already HAVE login privilege. But privileges |= LAPI_USERS.PRIV_LOGIN; DOES change the value if the user already has the login privilge.Any feedback?
Geoff_Price_(JTASCAdmin_(Delete)_1422989)
I'm using Java to try and determine if a user has privileges to add items to a folder, and if so, display an Add button. I want to expand it later to generate a drop down list of items that the user has privileges to create. I'm not sure how to tell if a user can actually add items. When the user browses into a folder, I display a header that gives a link back up a level, the name of the current folder, and (if they can add items) an add button. I have a line like this:
doc.GetObjectRights(volID, startAt, objRights);volID = the current volume ID
startAt = the current parentID
objRights is the LLValue where I then can retrieve the Permissions value.
I'm not sure how to use this value to determine what the user can do in this folder?
Any help would be appreciated.
Thanks,
Geoff
Tom__Turner_(BANONE02Admin_(Delete)_3045902)
public static boolean canEdit_Permissions(Permission perm) { if ((perm.asBitMask() & LAPI_DOCUMENTS.PERM_EDITPERMS) == LAPI_DOCUMENTS.PERM_EDITPERMS) return true; else return false; }
Geoff_Price_(JTASCAdmin_(Delete)_1422989)
Thanks for the reply. I did end up meeting an OpenText instructor at a recent convention and was talking to him about this. He provided me a sample page from the LAPI Course. I used what he gave me, but I ended up changing it to something like what you show.
Thanks!