1

My Business Requirement is to read the Users that are assigned to the different BusinessUnit's in our Enterprise Account. For testing purposes I'm using the PHP Library. Using the following code I'm able to read all Active BusinesUnit's:

// Create the retrieve request
$request = new ExactTarget_RetrieveRequest();
$objectType = "BusinessUnit"; 
$request->ObjectType= $objectType;
$request->QueryAllAccounts = true;
$request->Properties = array("ID","Description");

$filter1 = new ExactTarget_SimpleFilterPart() ;
$filter1->Property= "IsActive";
$filter1->SimpleOperator=ExactTarget_SimpleOperators::equals;
$filter1->Value=array("1");
// Attach the filter to the request
$request->Filter = new SoapVar($filter1, SOAP_ENC_OBJECT, 
                   'SimpleFilterPart', "http://exacttarget.com/wsdl/partnerAPI");

// Retrieve 
$requestMsg = new ExactTarget_RetrieveRequestMsg();
$requestMsg->RetrieveRequest=$request; 
$results = $client->Retrieve($requestMsg);   

In the next setp I want to iterate over the results and read the AccountUser assigned to each of the BusinessUnit's. Unfortunately for the AccountUser (http://help.exacttarget.com/en/technical_library/web_service_guide/objects/accountuser/) Retrieve method the BusinessUnit can't be defined as a filter criteria. So please let me know how I can read the AccountUsers assigned to the different BusinessUnit's.

1
  • I think you have to look by accountuser and view what they are associated good to, and not the other way around. Commented Feb 25, 2014 at 21:42

3 Answers 3

6

Setting an associated business unit is done like this:

  <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
     <Options/>
     <Objects xsi:type="AccountUser" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <Client>
           <ID>123610</ID>
        </Client>
        <UserID>ExampleNewUserForBU</UserID>
        <Password>password@1</Password>
        <Name>ExampleNewUserForBU</Name>
        <Email>[email protected]</Email>
        <MustChangePassword>false</MustChangePassword>
        <DefaultBusinessUnit>10665829</DefaultBusinessUnit>
        <AssociatedBusinessUnits>
           <BusinessUnit>
              <ID>10665829</ID>
           </BusinessUnit>
        </AssociatedBusinessUnits>
     </Objects>
  </CreateRequest>

To remove an associated business unit from user: 150022 is the account that owns the user. 150011 is the user. 150023 is the BU being removed from user.

  <soap:Body>
    <ConfigureRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
      <Action>assign</Action>
      <Configurations>
        <Configuration xsi:type="AccountUser">
          <Client>
            <ID>150022</ID>
          </Client>
          <ID>150011</ID>
          <BusinessUnitAssignmentConfiguration>
            <BusinessUnitIds>
              <BusinessUnitId>150023</BusinessUnitId>
            </BusinessUnitIds>
            <IsDelete>true</IsDelete>
            <IsReplace>false</IsReplace>
          </BusinessUnitAssignmentConfiguration>
        </Configuration>
      </Configurations>
    </ConfigureRequestMsg>
  </soap:Body>

To retrieve an assoc. BU:

<RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
   <RetrieveRequest>
      <ClientIDs>
         <ID>0000000</ID>
      </ClientIDs>
      <ObjectType>Account</ObjectType>
      <Properties>ID</Properties>
      <Properties>Name</Properties>
      <Properties>ParentID</Properties>
      <Properties>ParentName</Properties>
      <Properties>CustomerKey</Properties>
      <Properties>AccountType</Properties>
      <QueryAllAccounts>false</QueryAllAccounts>
   </RetrieveRequest>
</RetrieveRequestMsg> 

To retrieve BU's for a user:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soap:mustUnderstand="1">
        <wsse:UsernameToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-3">
            <wsse:Username>myuser</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">mypassword</wsse:Password>
        </wsse:UsernameToken>
    </wsse:Security>
</soap:Header>
<soap:Body>
    <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <RetrieveRequest>
            <ObjectType>AccountUserAccount</ObjectType>
            <Properties>AccountUser.Name</Properties>
            <Properties>AccountUser.AccountUserID</Properties>
            <Properties>AccountUser.Email</Properties>
            <Properties>AccountUser.UserID</Properties>
            <Properties>AccountUser.ActiveFlag</Properties>
            <Properties>Account.ID</Properties>
            <Properties>Account.Name</Properties>
            <Properties>Account.IsActive</Properties>
            <Properties>Account.CustomerID</Properties>
            <Filter xsi:type="SimpleFilterPart">
                <Property>AccountUser.AccountUserID</Property>
                <SimpleOperator>equals</SimpleOperator>
                <Value>7351261</Value>
            </Filter>
            <QueryAllAccounts>true</QueryAllAccounts>
            <Options>
                <Client>
                    <ID>7230402</ID>
                </Client>
            </Options>
        </RetrieveRequest>
    </RetrieveRequestMsg>
</soap:Body>

To retrieve users for a BU:

    <soap:Body>
    <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <RetrieveRequest>
            <ObjectType>AccountUserAccount</ObjectType>
            <Properties>AccountUser.Name</Properties>
            <Properties>AccountUser.AccountUserID</Properties>
            <Properties>AccountUser.Email</Properties>
            <Properties>AccountUser.UserID</Properties>
            <Properties>AccountUser.ActiveFlag</Properties>
            <Properties>Account.ID</Properties>
            <Properties>Account.Name</Properties>
            <Properties>Account.IsActive</Properties>
            <Properties>Account.CustomerID</Properties>
            <Filter xsi:type="SimpleFilterPart">
                <Property>Account.Id</Property>
                <SimpleOperator>equals</SimpleOperator>
                <Value>150029</Value>
            </Filter>
            <QueryAllAccounts>true</QueryAllAccounts>
            <Options>
                <Client>
                    <ID>150022</ID>
                </Client>
            </Options>
        </RetrieveRequest>
    </RetrieveRequestMsg>
</soap:Body>
1
  • 1
    While old these sir are golden nugget payloads. Thanks for sharing.
    – Vlad
    Commented Apr 7, 2018 at 16:20
1

This is not possible. The AssociatedBusinessUnits property on the AccountUser object is not retrievable.

See response from ExactTarget representative here: https://code.exacttarget.com/question/how-remove-account-users-all-associated-business-units

0

You will need to do a retrieve on the accountUser object, and filter on each accountUser by the AssociatedBusinessUnits. This will give you a listing of what you are looking for.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .