FTP Server migration using Sterling Secure Proxy – UserID based Dynamic Routing (page 4)

Export folder structure from VSFTPD to SB2BI Mailbox

For using Dynamic Routing the folder structure has to be identical on both the old and new environment to avoid issues for external users. My plan is to also here use Sterling Map Editor to create a map that uses an export file from the VSFTPD server to create a XAPI file to create the Mailboxes in SB2BI. And the use a Business Process to run the XAPI.

Get existing VSFTPD Folder Structure

I start by getting the existing folder structure from my old FTP Server. It is a simple structure where all folders for each user is stored under the var/www/ folder.

Skjermbilde 2016-01-11 kl. 11.16.33I copy this folder structure to a text-file, and use it as input to my map.

Sterling Map

My Map will take the folder structure as input, and create a XAPI XML Output. Since my folder structure and my user names is in sync, I have created one map that both creates the XAPI for createMailbox as well as createVirtualRoot.

On the input side I use a Indexed Flat File format. I use “/var” as Tag to identify each record. As well as at the same time remove the /var folder from the output, since I in SB2BI would like to have /www as the first folder level after the Root level in the same way as VSFTPD is configured to have /www as its Root level.

The Output side of the Map is based on the XAPI createMailbox and the XAPI createVirtualRoot XSD’s. But since both the createMailbox and createVirtualRoot XAPI’s is designed to only create one Mailbox and one Virtual Root, and not a complete structure, I create a XML file where I have Mailboxes as Root tag, and import the XML Schema for createMailbox and createVirtualRoot one level lower to allow looping to enable creating more Mailboxes and more Virtual Roots at once.

Skjermbilde 2016-01-12 kl. 00.40.44

Since not all folders should have a Virtual Root, I have chosen to have some custom code on the input side of the map to select the right information for the right fields, as well as only create Virtual Roots for the users Root folders.

The code looks like below:

string[1] wrkString;
integer length;
integer position;
integer slashExists;

length = len(#Folder);
position = length;
slashExists = -1;

//Find last slash in string
while slashExists = -1 do
begin
 position = position - 1;
 wrkString = mid(#Folder, position, 1);
 slashExists = strstr("/", wrkString);
end

//Populate createMailbox
$TempMailbox[counterMailbox].#Name = right(#Folder, length-position-1);

//For the Root folder / is set as Parent Path
if left(#Folder, position) = "" then
begin
 $TempMailbox[counterMailbox].#ParentPath = "/";
end
else
begin
 $TempMailbox[counterMailbox].#ParentPath = left(#Folder, position);
end

//Increments global variable for index
counterMailbox = counterMailbox+1;

//Populate createVirtualRoot if the folder name is user*
if strstr(right(#Folder, length-position-1),"user") != -1 then
begin
 $TempVirtualRoot[counterVirtualRoot].#VirtualRootUser = right(#Folder, length-position-1);
 $TempVirtualRoot[counterVirtualRoot].#VirtualRootPath = #Folder;

 //Increments global variable for index
 counterVirtualRoot = counterVirtualRoot+1;
end

Shortly described, the Extended Rule code uses String functions to find the last slash (/) in the path, and based on the position of that extracts what is before or after that position. For the Root folder, I add “/” if the ParentPath field is empty.

For the Virtual Root part, the Code checks if “user” is a part of the folder name. And if Yes, a Virtual Root is created.

This map is of course created to fit this folder structure and user name structure. So with a less simple structure, and maybe no connection between folder names and user names it is more difficult to automate. Thus it is always nice to have some kind of logic in the naming convention.

Business Process

The Business Process is the same as used on creating users, just with a different Map. It extracts each Mailbox and runs the XAPI towards SB2BI in a Loop until all Mailboxes are created. Then it dues the same for the Virtual Roots.

The BP Code is below:

<process name="ES_Create_Mailbox">
  <rule name="MoreMailboxes">
    <condition>Mailbox.DONE = 0</condition>
  </rule>

  <rule name="MoreVirtualRoots">
    <condition>VirtualRoot.DONE = 0</condition>
  </rule>

  <sequence name="Sequence Start">
    <operation name="Translation ES_VSFTPD_FOLDERSTRUCTURE_TO_XAPI">
      <participant name="Translation"/>
      <output message="TranslationTypeInputMessage">
        <assign to="map_name">ES_VSFTPD_FOLDERSTRUCTURE_TO_XAPI</assign>
        <assign to="output_report_to_process_data">YES</assign>
        <assign to="." from="*"></assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>

    <assign name="Assign" to="OriginalDocument" from="/ProcessData/PrimaryDocument/@SCIObjectID"></assign>
    <operation name="Document Extraction - Extract XAPI XML">
      <participant name="DocumentExtractionService"/>
      <output message="DocumentExtractionTypeInputMessage">
        <assign to="." from="*"></assign>
        <assign to="BatchLikeDocuments">NO</assign>
        <assign to="DocExtractMapList">ES_VSFTPD_FOLDERSTRUCTURE_TO_XAPI</assign>
        <assign to="PDToProcessData">NO</assign>
        <assign to="XMLInput">YES</assign>
        <assign to="XMLRootTag">Mailbox</assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>

    <sequence name="MailboxLoop">
      <operation name="For Each Document">
        <participant name="ForEachDocument"/>
        <output message="ForEachDocumentTypeInputMessage">
          <assign to="." from="*"></assign>
          <assign to="DOCUMENT_NAME_PREFIX">DOC-SPLIT-</assign>
          <assign to="ITERATOR_NAME">Mailbox</assign>
        </output>
        <input message="inmsg">
          <assign to="." from="*"></assign>
        </input>
      </operation>

      <choice name="MoreMailboxesLeft">
        <select>
          <case ref="MoreMailboxes" activity="Mailbox Create Start"/>
        </select>

        <sequence name="Mailbox Create Start">
          <assign name="Assign" to="PrimaryDocument" from="/ProcessData/PrimaryDocument/@SCIObjectID"></assign>
          <operation name="XAPI Service">
            <participant name="XAPIService"/>
            <output message="XAPIServiceTypeInputMessage">
              <assign to="." from="*"></assign>
              <assign to="api">createMailbox</assign>
              <assign to="UserId">admin</assign>
            </output>
            <input message="inmsg">
              <assign to="." from="*"></assign>
            </input>
          </operation>

          <repeat name="Repeat" ref="MailboxLoop"/>

        </sequence>
      </choice>
    </sequence>
    <assign name="Assign" to="PrimaryDocument" from="/ProcessData/OriginalDocument/@SCIObjectID"></assign>
    <operation name="Document Extraction - Extract XAPI XML">
      <participant name="DocumentExtractionService"/>
      <output message="DocumentExtractionTypeInputMessage">
        <assign to="." from="*"></assign>
        <assign to="BatchLikeDocuments">NO</assign>
        <assign to="DocExtractMapList">ES_VSFTPD_FOLDERSTRUCTURE_TO_XAPI</assign>
        <assign to="PDToProcessData">NO</assign>
        <assign to="XMLInput">YES</assign>
        <assign to="XMLRootTag">VirtualRoot</assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>

    <sequence name="VirtualRootLoop">
      <operation name="For Each Document">
        <participant name="ForEachDocument"/>
        <output message="ForEachDocumentTypeInputMessage">
          <assign to="." from="*"></assign>
          <assign to="DOCUMENT_NAME_PREFIX">DOC-SPLIT-</assign>
          <assign to="ITERATOR_NAME">VirtualRoot</assign>
        </output>
        <input message="inmsg">
          <assign to="." from="*"></assign>
        </input>
      </operation>

      <choice name="MoreVirtualRootsLeft">
        <select>
          <case ref="MoreVirtualRoots" activity="VirtualRoot Create Start"/>
        </select>

        <sequence name="VirtualRoot Create Start">
          <assign name="Assign" to="PrimaryDocument" from="/ProcessData/PrimaryDocument/@SCIObjectID"></assign>
          <operation name="XAPI Service">
            <participant name="XAPIService"/>
            <output message="XAPIServiceTypeInputMessage">
              <assign to="." from="*"></assign>
              <assign to="api">createVirtualRoot</assign>
              <assign to="UserId">admin</assign>
            </output>
            <input message="inmsg">
              <assign to="." from="*"></assign>
            </input>
          </operation>

          <repeat name="Repeat" ref="VirtualRootLoop"/>

        </sequence>
      </choice>
    </sequence>
  </sequence>
</process>

I run the Business Process with the Textfile I got from the VSFTPD Server as input, and ends up with the following Mailboxes on SB2BI.

Skjermbilde 2016-01-11 kl. 11.44.43

And the Virtual Roots is created as folows:

Change Group Permissions

Now when the Mailboxes is created and the Virtual Roots is created, everything is in place. But the users imported do not have Permissions to their own mailboxes. This can off course be set on each individual user, but since each individual user have their ovn Virtual Root, we can instead change the Group Permissions for the group “externalUsers” and give that group Permissions to all mailboxes under the /www folder.

So I go to the Accounts -> Groups and search for the “externalUsers” group. Click on “edit”.

Accounts - Groups

Go to “Assign Permissions” and search for “www”. Select all available Permissions and move them to “Assigned”.

Groups - Assign Permissions

It should now look like below. Save the changes.

Groups - Assign Permissions - Assigned

Summary

I am now finished with the migration part of this. Users are migrated from the VSFTPD Server to both the LDAP and SB2BI, and the folder structure are migrated and Virtual Roots are created. So the next steps will be the setup of the Dynamic Routing capability to enable moving users one by one in a controlled manner.

"FTP Server migration using Sterling Secure Proxy – UserID based Dynamic Routing" table of contents

  1. FTP Server migration using Sterling Secure Proxy – UserID based Dynamic Routing
  2. Export user/password from VSFTPD to LDAP
  3. Export users from VSFTPD to SB2BI
  4. Export folder structure from VSFTPD to SB2BI Mailbox
  5. Create setup in SEAS to fetch Routing Information from LDAP
  6. Create Policy, Netmap and Adapter in SSP for Dynamic Routing
  7. Test setup as is and routing to SB2BI
  8. Summary

0 comments on “FTP Server migration using Sterling Secure Proxy – UserID based Dynamic RoutingAdd yours →

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: