Community
Showing results for 
Search instead for 
Do you mean 
Reply

Change User Status

Nickel Super Contributor
Posts: 441
Country: UK

Change User Status

Does anyone have a sample of how to change a users status from Active to Inactive? I've tried User.SetStatus(Act.Framework.Users.Status.Inactive, ActFwk) but it throws a Method Access Exception......
 
Tom
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Change User Status

Hi Tom,
 
Looking at the ref it looks like the property has only been implemented as a readonly property. Smiley Sad
 
You might be possibly able to use something like:
 
bool bDeleteContactCard  = false; //or true if you want to delete the card.
bool bWasCardDeleted = false;
 
bWasCardDeleted = Act.Framework.UserManager.RemoveUser(oUser,bDeleteContactCard);
 
I haven't checked this but maybe it might work? Let me know.
 
Vivek.
Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
Nickel Super Contributor
Posts: 441
Country: UK

Re: Change User Status

Hi Vivek,
Thanks for the response... will the code you suggested not delete the user all be it leaving the contact record in place? I need to just set the user as inactive for a while so that I can re-activate them later.  The reason being is I frequently have to stop all users accessing a db for a while so I go into manage users and set them all as inactive so that they can't log in.  When I've finished what I was doing I go back into manage users and make everone active again.  It would just be nice to automate this processes.
 
Tom
Copper Contributor
Posts: 97
Country: USA

Re: Change User Status

Hi Tom,
 
Just wondering... is it not sufficient to lock the database for whatever you're doing?
 
                this._ActApp.ActFramework.Database.LockDatabase( DatabaseLockReason.General, "Doing maintenance" );
                this._ActApp.ActFramework.Database.UnlockDatabase();
jason
 
Jason Sellers
ACT! Engineer 2000-2007
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Change User Status

Hi Tom,
 
Yeah it will. Scarily though it seems to be about the only way presented by the SDK of carrying out an inactivation of a User. It seems a bit of a cumbersome means since I presume one would need to re-assign activities etc to another user!
It would be nice if the SDK could allow exposure of the status, one possible usage that comes to mind is say firing off an inactivation from an Active Directory event stating that a domain user has become inactive so that we do not have to repeat the task in ACT! I admit its not an everyday occurance but, hey why not? Smiley Happy
 
For the purpose you require, it would make more sense to go with Jason's post above since that is just locking the dB so that no other user can log into the dB whilst you carry out your maintenance.
 
Making users Inactive for such a task is a bit "heavy handed" I think personally, unless of course there are other reasons you haven't mentioned.
 
HTH,
 
Vivek
Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
Nickel Super Contributor
Posts: 441
Country: UK

Re: Change User Status

I've had this cross posted in the ACC newgroups and someone has pointed out that the reason the property may well have been set to read-only is to avoid people breaking licensing restrictions.  Locking the db would work for all users; the reason this all started is that I have a tool which batch creates users, and can batch copy them from db to db.  It also allows you to change roles, permissions and passwords of groups of users which you can select from a list view which I use for creating / editing large dbs.  Active/Inactive was the only option I havn't managed to incorperate from the manage users dialog, its not the end of the world I was just trying to include all the functionality.  Cool idea for active directory - would be nice to be able to pull in users details from there as well when you are deploying a new db Smiley Happy
 
Tom
New Member
Posts: 2
Country: Canada

Re: Change User Status

Users can be inactivated from the Tools | Manage Users
 
-----------------
 
Has anyone found if there's a login history created for users? I have some 25 active licences, with 5+ users wanting access.
 
I want to see if any of my current active users are using my database at all. If they're only viewing then I can create one guest list for them to share. But for those using it avidly and making updates I'd like to keep active.
 
I need to know how far we can hold off until I need to obtain more licences.
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Change User Status

Hiya,
 
I couldn't work out a way of getting a full history of logins but the following code gets you the last login:
 
string userName = "user1";
Act.Framework.User oUser = oFramework.Users.GetUser(userName);
MessageBox.Show(oUser.LastLogOnDate.ToString());
 
Unfortunately this doesn't show if they are updating records or just viewing but at least you might be able to find some users who have not even logged into the system?
 
HTH
 
Vivek
Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog