2013-05-24 11:54 AM
I am able to build console applications using the API fine, but trying to write a web service using ASP.NET Web API in C# that returns json/xml I've run into trouble with the way the PersistentSettings class is trying to store settings as User-Scoped vs. ApplicationScoped. I tried to create a function that loops through the setting properties attributes and removes the UserScoped spec and adds the Application scoped spec, I've tried clearing the settings all together and saving them, all to no avail.
Any pointers to get me moving in the right direction?
2013-05-24 12:02 PM
public class netappController : ApiController
public string getVol()
na = new NaFiler("filer.fqdn.com");
na.Credentials = new NetworkCredential("user","password");
na.Protocol = NetApp.ServerProtocol.HTTPS;
//Start of attempt at fixing
NetApp.PersistentSettings set = new NetApp.PersistentSettings();
SettingsPropertyCollection col = set.Properties;
foreach(SettingsProperty prop in col)
prop.Attributes.Add(typeof(ApplicationScopedSettingAttribute), new ApplicationScopedSettingAttribute());
//End of attempt at fixing
NetApp.Filer.Volume.VolumeGetFilerInfo input = new NetApp.Filer.Volume.VolumeGetFilerInfo();
NetApp.Filer.Volume.VolumeGetFilerInfoResult data = input.Invoke(na);
return "not working yet";
The same class works in a console application without the section of code to try and fix the settings scope.
2013-05-26 08:25 PM
I didn't realize there were two different versions of the .net SDK bindings. The newer version(i'm assuming as it has more complete type info) is less feature complete it seems, as it doesn't support RPC login without a password as well as having the user-scoped settings limitation. I have switched to using the ManageOntap.dll and haven't had any issues.
2013-06-01 11:31 AM
This Code has a little but important bug. You have to manipulate the default instance:
|// Fixing problem with user-scoped settings|
|PersistentSettings set = PersistentSettings.Default;|
|SettingsPropertyCollection col = set.Properties;|
|foreach(SettingsProperty prop in col)|
|prop.Attributes.Add(typeof(ApplicationScopedSettingAttribute), new ApplicationScopedSettingAttribute());|
|NaFiler server = new NaFiler(ADDRESS);|
|server.Credentials = new NetworkCredential(USER, PWD);|