Hi Naga Kiran, To De-activate Portal User in Apex Code.The below code snippet might help.
// Assume cIds is a list of Contacts whose users we wish to deactivate
List<User> usersToUpdate = new List<User>();
for(User u : [Select u.Id, u.IsActive, u.IsPortalEnabled from User u where u.ContactId in :cIds]){
if(u.IsActive || u.IsPortalEnabled ){
u.IsActive = false;
u.IsPortalEnabled = false;
usersToUpdate.add(u);
}
}
if (usersToUpdate.size()>0){
update usersToUpdate;
}
To De-activate Portal User in Apex Code.The below code snippet might help. Please refer the below link for reference.
- https://salesforce.stackexchange.com/questions/17389/how-do-i-deactivate-a-portal-user-in-apex-code
- https://developer.salesforce.com/forums/?id=906F000000090mcIAA
Hope it will be helpful.Please mark it as best answer if the information is informative.
Thanks
Rahul Kumar