Software Development Kit (SDK) and API Discussions

NMSDK 5.1 - .NET UserScopedSettings vs. ApplicationScopedSettings

austin_workman
3,367 Views

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?

5 REPLIES 5

austin_workman
3,367 Views

public class netappController : ApiController

    {

        public string getVol()

        {

            NaFiler na;

            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.Clear();

                prop.Attributes.Remove(typeof(UserScopedSettingAttribute));

                prop.Attributes.Add(typeof(ApplicationScopedSettingAttribute), new ApplicationScopedSettingAttribute());

            }

            set.Save();

            set.Reload();

            //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.

PATRICK_WEIBEL
3,367 Views

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.Remove(typeof(UserScopedSettingAttribute));
   prop.Attributes.Add(typeof(ApplicationScopedSettingAttribute), new ApplicationScopedSettingAttribute());
   }

   NaFiler server = new NaFiler(ADDRESS);
   server.Credentials = new NetworkCredential(USER, PWD);

netappusermatt
3,367 Views

Thanks Patrick this really helped me out!

austin_workman
3,367 Views

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.

dhivya
3,367 Views

We are investigating on changing the default scope. We will get back to you on this.

Public