You need to sign in to do that
Don't have an account?

I am getting DML operation error in SamlJitHandler
Hi All,
I am getting DML opration error In SamlJitHandler During parameter passing from identity provider (3rd Party) .
include parameter here(UserName,AccountOwner,ContactLastName,ContactFirstName,ContactEmail,userLastName,userFirstName,UserFederationidentyfier,AccountNumber,userCommunityNickName)
I am using Controller is
global class StandardUserHandler implements Auth.SamlJitHandler {
private class JitException extends Exception{}
private void handleUser(boolean create, User u, Map<String, String> attributes, String federationIdentifier, boolean isStandard)
{
if(create && attributes.containsKey('User.Username'))
{
u.Username = attributes.get('User.Username');
}
if(create)
{
if(attributes.containsKey('User.FederationIdentifier'))
{
u.FederationIdentifier = attributes.get('User.FederationIdentifier');
} else
{
u.FederationIdentifier = federationIdentifier;
}
}
if(attributes.containsKey('User.ProfileId'))
{
String profileId = attributes.get('User.ProfileId');
Profile p = [SELECT Id FROM Profile WHERE Id=:profileId]; u.ProfileId = p.Id;
}
if(attributes.containsKey('User.UserRoleId'))
{
String userRole = attributes.get('User.UserRoleId');
UserRole r = [SELECT Id FROM UserRole WHERE Id=:userRole];
u.UserRoleId = r.Id; } if(attributes.containsKey('User.Phone'))
{
u.Phone = attributes.get('User.Phone');
}
if(attributes.containsKey('User.Email'))
{
u.Email = attributes.get('User.Email');
}
if(!create)
{
update(u);
}
}
private void handleJit(boolean create, User u, Id samlSsoProviderId, Id communityId, Id portalId, String federationIdentifier, Map<String, String> attributes, String assertion) {
if(communityId != null || portalId != null)
{
String account = handleAccount(create, u, attributes); handleContact(create, account, u, attributes); handleUser(create, u, attributes, federationIdentifier, false);
} else
{
handleUser(create, u, attributes, federationIdentifier, true);
}
}
global User createUser(Id samlSsoProviderId, Id communityId, Id portalId, String federationIdentifier, Map<String, String> attributes, String assertion) {
User u = new User(); handleJit(true, u, samlSsoProviderId, communityId, portalId, federationIdentifier, attributes, assertion); return u;
}
global void updateUser(Id userId, Id samlSsoProviderId, Id communityId, Id portalId, String federationIdentifier, Map<String, String> attributes, String assertion)
{
User u = [SELECT Id FROM User WHERE Id=:userId]; handleJit(false, u, samlSsoProviderId, communityId, portalId, federationIdentifier, attributes, assertion);
}
}
Please suggest what to be changes needed in this controller ;
I am getting DML opration error In SamlJitHandler During parameter passing from identity provider (3rd Party) .
include parameter here(UserName,AccountOwner,ContactLastName,ContactFirstName,ContactEmail,userLastName,userFirstName,UserFederationidentyfier,AccountNumber,userCommunityNickName)
I am using Controller is
global class StandardUserHandler implements Auth.SamlJitHandler {
private class JitException extends Exception{}
private void handleUser(boolean create, User u, Map<String, String> attributes, String federationIdentifier, boolean isStandard)
{
if(create && attributes.containsKey('User.Username'))
{
u.Username = attributes.get('User.Username');
}
if(create)
{
if(attributes.containsKey('User.FederationIdentifier'))
{
u.FederationIdentifier = attributes.get('User.FederationIdentifier');
} else
{
u.FederationIdentifier = federationIdentifier;
}
}
if(attributes.containsKey('User.ProfileId'))
{
String profileId = attributes.get('User.ProfileId');
Profile p = [SELECT Id FROM Profile WHERE Id=:profileId]; u.ProfileId = p.Id;
}
if(attributes.containsKey('User.UserRoleId'))
{
String userRole = attributes.get('User.UserRoleId');
UserRole r = [SELECT Id FROM UserRole WHERE Id=:userRole];
u.UserRoleId = r.Id; } if(attributes.containsKey('User.Phone'))
{
u.Phone = attributes.get('User.Phone');
}
if(attributes.containsKey('User.Email'))
{
u.Email = attributes.get('User.Email');
}
if(!create)
{
update(u);
}
}
private void handleJit(boolean create, User u, Id samlSsoProviderId, Id communityId, Id portalId, String federationIdentifier, Map<String, String> attributes, String assertion) {
if(communityId != null || portalId != null)
{
String account = handleAccount(create, u, attributes); handleContact(create, account, u, attributes); handleUser(create, u, attributes, federationIdentifier, false);
} else
{
handleUser(create, u, attributes, federationIdentifier, true);
}
}
global User createUser(Id samlSsoProviderId, Id communityId, Id portalId, String federationIdentifier, Map<String, String> attributes, String assertion) {
User u = new User(); handleJit(true, u, samlSsoProviderId, communityId, portalId, federationIdentifier, attributes, assertion); return u;
}
global void updateUser(Id userId, Id samlSsoProviderId, Id communityId, Id portalId, String federationIdentifier, Map<String, String> attributes, String assertion)
{
User u = [SELECT Id FROM User WHERE Id=:userId]; handleJit(false, u, samlSsoProviderId, communityId, portalId, federationIdentifier, attributes, assertion);
}
}
Please suggest what to be changes needed in this controller ;

Plaease help and give any posible solution

This is for commuity user