public void SetPropertyKeyValue(string key, object value)
        {
            if (value == null || value == Undefined.Value || value == Null.Value)
            {
                throw new ArgumentNullException("value");
            }

            string stringValue;

            if (value is ObjectInstance)
            {
                stringValue = JSONObject.Stringify(Engine, value, null, null);
            }
            else
            {
                stringValue = value.ToString();
            }

            if (m_iisWebServiceApplication.Properties.ContainsKey(key))
            {
                m_iisWebServiceApplication.Properties[key] = stringValue;
            }
            else
            {
                m_iisWebServiceApplication.Properties.Add(key, stringValue);
            }

            m_iisWebServiceApplication.Update();
        }
Esempio n. 2
0
        internal static OutputQueue EnsureUserAccess(string accountName = null)
        {
            var outputQueue = new OutputQueue();

            if (string.IsNullOrEmpty(accountName))
            {
                accountName = WindowsIdentity.GetCurrent().Name;
            }

            var mossContext = SPServiceContext.GetContext(SPServiceApplicationProxyGroup.Default, new SPSiteSubscriptionIdentifier(Guid.Empty));

            using (var scope = new SPServiceContextScope(mossContext))
            {
                SPIisWebServiceApplication app = null;
                outputQueue.Add(GetUserProfileApplication(out app));
                if (app != null)
                {
                    var isAdmin = false;
                    outputQueue.Add(UserIsAdministrator(out isAdmin, accountName));
                    if (!isAdmin)
                    {
                        var aac = app.GetAdministrationAccessControl();
                        aac.AddAccessRule(new SPAclAccessRule <SPCentralAdministrationRights>(new NTAccount(accountName), SPCentralAdministrationRights.FullControl));
                        app.SetAdministrationAccessControl(aac);
                    }

                    var hasAccess = false;
                    outputQueue.Add(UserHasAccess(out hasAccess, accountName));
                    if (!hasAccess)
                    {
                        var ac = app.GetAccessControl();
                        ac.AddAccessRule(new SPAclAccessRule <SPIisWebServiceApplicationRights>(new NTAccount(accountName), SPIisWebServiceApplicationRights.FullControl));
                        app.SetAccessControl(ac);
                    }
                    app.Update();
                }
            }

            return(outputQueue);
        }