+ Start a Discussion
Arvind010Arvind010 

How to assign a profile to the user?

I want to assign a profile to the user.I used the following code:

User SPPuser = new User();
Profile prof = [Select id,Name from Profile where Name = 'Partner Admin User'];       
SPPuser.Profile = prof.id;
I am getting an error like:Illegal assignment from Id to SOBJECT:Profile

Please provide me the solution.
OzymandiasOzymandias
Try changing the last line to:

SPPuser.ProfileId = prof.id

As the error says, SPPuser.Profile expects an SObject, not an id.