I have the requirement of changing the configuration elements (servicename, username, password) of all SQLServerSpatial FeatureSources in a library.
I thought this would be a perfect test case for Jackies "IronPython Console" in Maestro especially since I haven't written a python script before.
Changing the servicename was no problem but now I'm struggling with changing the user credentials.
I thought I just have to use the SetEncryptedCredentials method of the FeatureSource but this ended up in this error:
AttributeError: 'FeatureSourceType' object has no attribute 'SetEncryptedCredentials'
This error is also thrown on other methods like GetConfigurationContent or GetConnectionProperties.
That is what I have so far:
def ChangeSQLServerFeatureSources(conn, folder, oldServiceName, newServiceName, userName, password):
Changes all SQLServer FeatureSources with the specified oldServiceName
resList = conn.ResourceService.GetRepositoryResources(folder, "FeatureSource")
for child in resList.Children:
fs = conn.ResourceService.GetResource(child.ResourceId)
if (fs.Provider == 'OSGeo.SQLServerSpatial' ):
if (fs.GetConnectionProperty('Service') == oldServiceName):
fs.SetEncryptedCredentials(userName,password) """ ERROR """
print fs.ResourceID + ": Changed '%s' to '%s'" % (oldServiceName, newServiceName)