Hi,
We are using ArcGIS Desktop 10.4 with Python 2.7.10.
We trying to automate the task of rebuilding the indexes on tables/feature classes owned by the user account part of the regular multi-user geodatabase maintenance. We can rebuild the indexes on the user tables manually without any problems using Data Owner account. However, when using the python script example provided in the Esri's help - Rebuild Indexes—Help | ArcGIS Desktop (pasted below),
<SPAN class="comment token"># Import system modules</SPAN>
<SPAN class="keyword token">import</SPAN> arcpy<SPAN class="punctuation token">,</SPAN> os
<SPAN class="comment token"># set workspace</SPAN>
workspace <SPAN class="operator token">=</SPAN> <SPAN class="string token">"E:/sde/SDE_Data_Owner.sde"</SPAN>
<SPAN class="comment token"># set the workspace environment</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> workspace
<SPAN class="comment token"># NOTE: Rebuild indexes can accept a Python list of datasets.</SPAN>
<SPAN class="comment token"># Get a list of all the datasets the user has access to.</SPAN>
<SPAN class="comment token"># First, get all the stand alone tables, feature classes and rasters.</SPAN>
dataList <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListTables<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListFeatureClasses<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListRasters<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Next, for feature datasets get all of the datasets and featureclasses</SPAN>
<SPAN class="comment token"># from the list and add them to the master list.</SPAN>
<SPAN class="keyword token">for</SPAN> dataset <SPAN class="keyword token">in</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListDatasets<SPAN class="punctuation token">(</SPAN><SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Feature"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>workspace<SPAN class="punctuation token">,</SPAN>dataset<SPAN class="punctuation token">)</SPAN>
dataList <SPAN class="operator token">+=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListFeatureClasses<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListDatasets<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># reset the workspace</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> workspace
<SPAN class="comment token"># Get the user name for the workspace</SPAN>
userName <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Describe<SPAN class="punctuation token">(</SPAN>workspace<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>connectionProperties<SPAN class="punctuation token">.</SPAN>user<SPAN class="punctuation token">.</SPAN>lower<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># remove any datasets that are not owned by the connected user.</SPAN>
userDataList <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>ds <SPAN class="keyword token">for</SPAN> ds <SPAN class="keyword token">in</SPAN> dataList <SPAN class="keyword token">if</SPAN> ds<SPAN class="punctuation token">.</SPAN>lower<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>find<SPAN class="punctuation token">(</SPAN><SPAN class="string token">".%s."</SPAN> <SPAN class="operator token">%</SPAN> userName<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">></SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token"># Execute rebuild indexes</SPAN>
<SPAN class="comment token"># Note: to use the "SYSTEM" option the workspace user must be an administrator.</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>RebuildIndexes_management<SPAN class="punctuation token">(</SPAN>workspace<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"NO_SYSTEM"</SPAN><SPAN class="punctuation token">,</SPAN> userDataList<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"ALL"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Rebuild Complete'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Unfortunately, the python script throws following error message for line 33 above. I feel that it is not liking the userDataList variable?

Any assistance in resolving this would be appreciated.
Thank you.