• waprau
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies

I want to disable a User programmetically by using SOAP API. How can I do that? I am using Partner API and I have developer edition. I have manage users persmissions set. I have gone through this link. I am looking for code which can help me disable/deactivate a User.

 

This is my code:

 

    import com.sforce.soap.partner.Connector;
    import com.sforce.soap.partner.PartnerConnection;
    import com.sforce.soap.partner.QueryResult;
    import com.sforce.soap.partner.sobject.SObject;
    import com.sforce.ws.ConnectionException;
    import com.sforce.ws.ConnectorConfig;
    
    public class DeactivateUser {
    	public static void main(String[] args) {
    		ConnectorConfig config = new ConnectorConfig();
    		
    		config.setUsername("waprau@waprau.com");
    		config.setPassword("sjjhggrhgfhgffjdgj");
    
    		PartnerConnection connection = null;
    		
    		try {
    			connection = Connector.newConnection(config);
    			QueryResult queryResults = connection.query("SELECT Username, IsActive from User");
    
			if (queryResults.getSize() > 0) {
				for (SObject s : queryResults.getRecords()) {
					if(s.getField("Username").equals("abcd@pqrs.com")){
						System.out.println("Username: " + s.getField("Username"));
						s.setField("IsActive", false);
					}
					System.out.println("Username: " + s.getField("Username") + " IsActive: " + s.getField("IsActive"));
				}
			}
    		} catch (ConnectionException ce) {
    			ce.printStackTrace();
    		}
    	}
    }

 

This is output:

 

    Username: waprau@waprau.com IsActive: true
    Username: jsmith@ymail.net IsActive: false
    Username: abcd@pqrs.com
    Username: abcd@pqrs.com IsActive: false

 

However in UI when I go to My Name > Setup > Manage Users > Users, it always show 'Active' check box for user abcd@pqrs.com selected :-(

Thanks,
Wap Rau

  • September 20, 2012
  • Like
  • 0

I am newbie. I want to create a user with SOAP Partner WSDL. Can any one point me to examples or resources? I have read here that you can create users via the regular partner APIs. However, I am not able to find any.

 

Thanks,

Wap Rau

  • September 18, 2012
  • Like
  • 0

I am very new to SalesForce.

 

Is there any API which can do user provisioning from outside SalesForce? 

 

Any third party API to achieve this?

 

Thanks,

Wap Rau

  • September 14, 2012
  • Like
  • 0

I am newbie. I want to create a user with SOAP Partner WSDL. Can any one point me to examples or resources? I have read here that you can create users via the regular partner APIs. However, I am not able to find any.

 

Thanks,

Wap Rau

  • September 18, 2012
  • Like
  • 0

I am very new to SalesForce.

 

Is there any API which can do user provisioning from outside SalesForce? 

 

Any third party API to achieve this?

 

Thanks,

Wap Rau

  • September 14, 2012
  • Like
  • 0