public static bool Create(MSSQLConnector conn)
            {
                using (var bl = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
                {
                    bl.TableCreate(TableName, Columns);

                    return(((IDataConnector)conn).ExecuteNonQuery(bl) > 0);
                }
            }
Beispiel #2
0
        public bool Exists(MSSQLConnector conn)
        {
            using (var sb = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ProcedureExists(Name);

                return(((IDataConnector)conn).Execute(sb));
            }
        }
            public static bool Exists(MSSQLConnector conn)
            {
                using (var bl = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
                {
                    bl.TableExists(TableName);

                    return(((IDataConnector)conn).Execute(bl));
                }
            }
        bool IPermissionHandler.RemoveGroup(string name)
        {
            using (var sb = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.RemoveGroup, "prm",
                                    new DataParameter("Name", name)
                                    );

                return(Storage.ExecuteNonQuery(sb) > 0);
            }
        }
        NodePermission[] IPermissionHandler.UserNodes(string username)
        {
            using (var sb = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.UserNodes, "prm",
                                    new DataParameter("UserName", username)
                                    );

                return(Storage.ExecuteArray <NodePermission>(sb));
            }
        }
Beispiel #6
0
        public bool Create(MSSQLConnector conn)
        {
            using (var sb = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                var proc = PluginContent.GetResource("TDSM.Data.MSSQL.Procedures.Files." + Name + ".sql");

                sb.CommandType = System.Data.CommandType.Text;
                sb.CommandText = proc;

                return(((IDataConnector)conn).Execute(sb));
            }
        }
        public static long Insert(MSSQLConnector conn, long groupId, long permissionId)
        {
            using (var bl = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                bl.InsertInto(TableDefinition.TableName,
                              new DataParameter(TableDefinition.ColumnNames.GroupId, groupId),
                              new DataParameter(TableDefinition.ColumnNames.PermissionId, permissionId)
                              );

                return(((IDataConnector)conn).ExecuteInsert(bl));
            }
        }
        bool IPermissionHandler.RemoveUserFromGroup(string username, string groupName)
        {
            using (var sb = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.RemoveUserFromGroup, "prm",
                                    new DataParameter("UserName", username),
                                    new DataParameter("GroupName", groupName)
                                    );

                return(Storage.ExecuteScalar <Int64>(sb) > 0);
            }
        }
        private Permission IsPermitted(string node, bool isGuest, string authentication = null)
        {
            using (var sb = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.IsPermitted, "prm",
                                    new DataParameter("Node", node),
                                    new DataParameter("IsGuest", isGuest),
                                    new DataParameter("Authentication", authentication)
                                    );

                return((Permission)Storage.ExecuteScalar <Int32>(sb));
            }
        }
        bool IPermissionHandler.RemoveNodeFromUser(string username, string node, Permission permission)
        {
            using (var sb = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.RemoveNodeFromUser, "prm",
                                    new DataParameter("UserName", username),
                                    new DataParameter("Node", node),
                                    new DataParameter("Permission", permission)
                                    );

                return(Storage.ExecuteScalar <Int64>(sb) > 0);
            }
        }
        bool IPermissionHandler.AddGroupNode(string groupName, string node, Permission permission)
        {
            using (var sb = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.AddGroupNode, "prm",
                                    new DataParameter("GroupName", groupName),
                                    new DataParameter("Node", node),
                                    new DataParameter("Permission", permission)
                                    );

                return(Storage.ExecuteScalar <Int64>(sb) > 0);
            }
        }
        string[] IPermissionHandler.GroupList()
        {
            using (var sb = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.GroupList);

                var lst = Storage.ExecuteArray <GroupList>(sb);
                if (lst != null)
                {
                    return(lst.Select(x => x.Name).ToArray());
                }
            }
            return(null);
        }
        string[] IPermissionHandler.UserGroupList(string username)
        {
            using (var sb = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.UserGroupList, "prm",
                                    new DataParameter("UserName", username)
                                    );

                var lst = Storage.ExecuteArray <UserGroupList>(sb);
                if (lst != null)
                {
                    return(lst.Select(x => x.Name).ToArray());
                }
            }
            return(null);
        }
        Group IPermissionHandler.FindGroup(string name)
        {
            using (var sb = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.FindGroup, "prm",
                                    new DataParameter("Name", name)
                                    );

                var arr = Storage.ExecuteArray <Group>(sb);
                if (arr != null && arr.Length > 0)
                {
                    return(arr[0]);
                }
            }

            return(null);
        }
        bool IPermissionHandler.AddOrUpdateGroup(string name, bool applyToGuests, string parent, byte r, byte g, byte b, string prefix, string suffix)
        {
            using (var sb = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.AddOrUpdateGroup, "prm",
                                    new DataParameter("Name", name),
                                    new DataParameter("ApplyToGuests", applyToGuests),
                                    new DataParameter("Parent", parent),
                                    new DataParameter("R", r),
                                    new DataParameter("G", g),
                                    new DataParameter("B", b),
                                    new DataParameter("Prefix", prefix),
                                    new DataParameter("Suffix", suffix)
                                    );

                return(Storage.ExecuteScalar <Int64>(sb) > 0);
            }
        }
        /// <summary>
        /// Gets the first guest group from the database
        /// </summary>
        /// <returns>The guest group.</returns>
        Group IPermissionHandler.GetGuestGroup()
        {
            using (var sb = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.SelectAll(GroupTable.TableDefinition.TableName, new WhereFilter[]
                {
                    new WhereFilter(GroupTable.TableDefinition.ColumnNames.ApplyToGuests, true)
                });

                var arr = Storage.ExecuteArray <Group>(sb);
                if (arr != null)
                {
                    return(arr.FirstOrDefault());
                }
            }

            return(null);
        }