コード例 #1
0
 public Login(
     SqlString name,
     SqlString type,
     SqlInt32 id,
     SqlBinary sid,
     SqlString serveraccess,
     SqlString serverdeny,
     SqlString disabled,
     SqlString isexpirationchecked,
     SqlString ispolicychecked,
     SqlString ispasswordnull,
     SqlString defaultdatabase,
     SqlString defaultlanguage,
     SqlInt32 passwordStatus
     )
 {
     m_Name                = name.Value;
     m_Type                = Sql.ObjectType.LoginType(type);
     m_Id                  = id.Value;
     m_Sid                 = new Sid(sid.Value);
     m_ServerAccess        = Sql.ObjectType.ToBoolean(serveraccess);
     m_ServerDeny          = Sql.ObjectType.ToBoolean(serverdeny.Value);
     m_IsDisabled          = Sql.ObjectType.ToNullableBoolean(disabled);
     m_IsExpirationChecked = Sql.ObjectType.ToNullableBoolean(isexpirationchecked);
     m_IsPolicyChecked     = Sql.ObjectType.ToNullableBoolean(ispolicychecked);
     m_IsPasswordNull      = Sql.ObjectType.ToNullableBoolean(ispasswordnull);
     m_DefaultDatabase     = defaultdatabase.ToString();
     m_DefaultLanguage     = defaultlanguage.ToString();
     m_PasswordStatus      = passwordStatus.IsNull ? "N/A" : Utility.DescriptionHelper.GetEnumDescription((PasswordStatus)passwordStatus.Value);
 }
コード例 #2
0
ファイル: SqlTypes.cs プロジェクト: roshnimehata/SQLSecure
        public ObjectTag( // Database objects - table, view, function, stored proc, etc.
            int snapshotid,
            Sql.ObjectType.TypeEnum objType,
            Sql.Database database,
            int classId,
            int parentObjectId,
            int objectId,
            string objectName
            )
        {
            Debug.Assert(snapshotid != 0);
            Debug.Assert(objType == ObjectType.TypeEnum.Table ||
                         objType == ObjectType.TypeEnum.View ||
                         objType == ObjectType.TypeEnum.Synonym ||
                         objType == ObjectType.TypeEnum.StoredProcedure ||
                         objType == ObjectType.TypeEnum.Function ||
                         objType == ObjectType.TypeEnum.ExtendedStoredProcedure ||
                         objType == ObjectType.TypeEnum.Assembly ||
                         objType == ObjectType.TypeEnum.UserDefinedDataType ||
                         objType == ObjectType.TypeEnum.XMLSchemaCollection ||
                         objType == ObjectType.TypeEnum.FullTextCatalog ||
                         objType == ObjectType.TypeEnum.SequenceObjects ||
                         objType == ObjectType.TypeEnum.SequenceObject);
            Debug.Assert(database != null);
            Debug.Assert(!string.IsNullOrEmpty(objectName));

            m_SnapshotId     = snapshotid;
            m_ObjType        = objType;
            m_Database       = database;
            m_ClassId        = classId;
            m_ParentObjectId = parentObjectId;
            m_ObjectId       = objectId;
            m_ObjectName     = objectName;
        }
コード例 #3
0
ファイル: SqlTypes.cs プロジェクト: roshnimehata/SQLSecure
        public ObjectTag( // Database user, role, schema, cert and key objects.
            int snapshotid,
            Sql.ObjectType.TypeEnum objType,
            Sql.Database database,
            int objectId,
            string objectName
            )
        {
            Debug.Assert(snapshotid != 0);
            Debug.Assert(objType == ObjectType.TypeEnum.User ||
                         objType == ObjectType.TypeEnum.DatabaseRole ||
                         objType == ObjectType.TypeEnum.ApplicationRole ||
                         objType == ObjectType.TypeEnum.Key ||
                         objType == ObjectType.TypeEnum.Certificate);
            Debug.Assert(database != null);
            Debug.Assert(!string.IsNullOrEmpty(objectName));

            m_SnapshotId = snapshotid;
            m_ObjType    = objType;
            m_Database   = database;
            switch (m_ObjType)
            {
            case ObjectType.TypeEnum.User:
            case ObjectType.TypeEnum.DatabaseRole:
            case ObjectType.TypeEnum.ApplicationRole:
            case ObjectType.TypeEnum.Key:
            case ObjectType.TypeEnum.Certificate:
                m_ClassId = 4;
                break;
            }
            m_ObjectId   = objectId;
            m_ObjectName = objectName;
        }
コード例 #4
0
ファイル: SqlTypes.cs プロジェクト: roshnimehata/SQLSecure
        public ObjectTag( // database and database level tree view containers
            int snapshotId,
            Sql.ObjectType.TypeEnum objType,
            Sql.Database database
            )
        {
            Debug.Assert(snapshotId != 0);
            Debug.Assert(objType == ObjectType.TypeEnum.DatabaseSecurity ||
                         objType == ObjectType.TypeEnum.Users ||
                         objType == ObjectType.TypeEnum.DatabaseRoles ||
                         objType == ObjectType.TypeEnum.Schemas ||
                         objType == ObjectType.TypeEnum.Keys ||
                         objType == ObjectType.TypeEnum.Certificates ||
                         objType == ObjectType.TypeEnum.Tables ||
                         objType == ObjectType.TypeEnum.Views ||
                         objType == ObjectType.TypeEnum.Synonyms ||
                         objType == ObjectType.TypeEnum.StoredProcedures ||
                         objType == ObjectType.TypeEnum.Functions ||
                         objType == ObjectType.TypeEnum.ExtendedStoredProcedures ||
                         objType == ObjectType.TypeEnum.Assemblies ||
                         objType == ObjectType.TypeEnum.UserDefinedDataTypes ||
                         objType == ObjectType.TypeEnum.XMLSchemaCollections ||
                         objType == ObjectType.TypeEnum.FullTextCatalogs ||
                         objType == ObjectType.TypeEnum.SequenceObjects);
            Debug.Assert(database != null);

            m_SnapshotId = snapshotId;
            m_ObjType    = objType;
            m_Database   = database;
        }
コード例 #5
0
ファイル: SqlTypes.cs プロジェクト: roshnimehata/SQLSecure
        public ObjectTag( // server level objects
            int snapshotId,
            Sql.ObjectType.TypeEnum objType,
            int objectId,
            string objectName,
            object tag
            )
        {
            Debug.Assert(snapshotId != 0);
            Debug.Assert(
                objType == ObjectType.TypeEnum.File ||
                objType == ObjectType.TypeEnum.RegistryKey ||
                objType == ObjectType.TypeEnum.Service ||
                objType == ObjectType.TypeEnum.SqlLogin ||
                objType == ObjectType.TypeEnum.WindowsGroupLogin ||
                objType == ObjectType.TypeEnum.WindowsUserLogin ||
                objType == ObjectType.TypeEnum.ServerRole ||
                objType == ObjectType.TypeEnum.ServerRole ||
                objType == ObjectType.TypeEnum.AvailabilityGroup ||
                objType == ObjectType.TypeEnum.AvailabilityGroupReplica ||
                objType == ObjectType.TypeEnum.Endpoint ||
                objType == ObjectType.TypeEnum.AzureADUser ||
                objType == ObjectType.TypeEnum.AzureADGroup
                );
            Debug.Assert(!string.IsNullOrEmpty(objectName));

            m_SnapshotId = snapshotId;
            m_ObjType    = objType;
            m_ObjectId   = objectId;
            m_ObjectName = objectName;
            m_ClassId    = m_ObjType == ObjectType.TypeEnum.Endpoint ? 105 : 101;
            Tag          = tag;
        }
コード例 #6
0
ファイル: SqlTypes.cs プロジェクト: roshnimehata/SQLSecure
        public ObjectTag( // Database, and schema objects.
            int snapshotid,
            Sql.ObjectType.TypeEnum objType,
            Sql.Database database,
            int classId,
            int objectId,
            string objectName
            )
        {
            Debug.Assert(snapshotid != 0);
            Debug.Assert(objType == ObjectType.TypeEnum.Database ||
                         objType == ObjectType.TypeEnum.Schema);
            Debug.Assert(database != null);
            Debug.Assert(!string.IsNullOrEmpty(objectName));

            m_SnapshotId = snapshotid;
            m_ObjType    = objType;
            m_Database   = database;
            m_ClassId    = classId;
            m_ObjectId   = objectId;
            m_ObjectName = objectName;
        }
コード例 #7
0
ファイル: SqlTypes.cs プロジェクト: roshnimehata/SQLSecure
        public ObjectTag( // snapshot, server and server level tree view containers.
            int snapshotId,
            Sql.ObjectType.TypeEnum objType
            )
        {
            Debug.Assert(objType == ObjectType.TypeEnum.Snapshot ||
                         objType == ObjectType.TypeEnum.Server ||
                         objType == ObjectType.TypeEnum.Environment ||
                         objType == ObjectType.TypeEnum.FileSystem ||
                         objType == ObjectType.TypeEnum.Registry ||
                         objType == ObjectType.TypeEnum.Services ||
                         objType == ObjectType.TypeEnum.ServerSecurity ||
                         objType == ObjectType.TypeEnum.Logins ||
                         objType == ObjectType.TypeEnum.ServerRoles ||
                         objType == ObjectType.TypeEnum.ServerObjects ||
                         objType == ObjectType.TypeEnum.Endpoints ||
                         objType == ObjectType.TypeEnum.AvailabilityGroups ||
                         objType == ObjectType.TypeEnum.Databases);
            Debug.Assert(objType == ObjectType.TypeEnum.Snapshot ? true : snapshotId != 0);

            m_SnapshotId = snapshotId;
            m_ObjType    = objType;
            m_ClassId    = m_ObjType == ObjectType.TypeEnum.Server ? 100 : 0;
        }
コード例 #8
0
        private DataTable getGridDisplayTbl(DataSet ds)
        {
            // Fill the return data table.
            DataTable dt = null;

            if (ds != null && ds.Tables.Count > 0)
            {
                // Create data table object with selected columns.
                DataView dv = new DataView(ds.Tables[0]);
                dt = dv.ToTable("Permissions", true,
                                new string[] {
                    colGrantee, colPermission, colGrant, colWithGrant, colDeny, colGrantor,
                    colObjectName, colObjectTypeName, colObjectType,
                    colSourcePermission, colInherited, colSourceName, colSourceType
                });

                // Add the icon column to the begining of the data table.
                dt.Columns.Add(colIcon, typeof(Image));
                dt.Columns[colIcon].SetOrdinal(IconIndex);

                // Add permission check boxes.
                dt.Columns.Add(colGrantCheckBox, typeof(bool));
                dt.Columns[colGrantCheckBox].SetOrdinal(GrantIndex);
                dt.Columns.Add(colWithGrantCheckBox, typeof(bool));
                dt.Columns[colWithGrantCheckBox].SetOrdinal(WithGrantIndex);
                dt.Columns.Add(colDenyCheckBox, typeof(bool));
                dt.Columns[colDenyCheckBox].SetOrdinal(DenyIndex);

                // Process each row for additional info.
                m_IsColumn = false;
                foreach (DataRow row in dt.Rows)
                {
                    //Get the type of object.
                    Sql.ObjectType.TypeEnum type = Sql.ObjectType.ToTypeEnum(row[colObjectType].ToString());
                    row[colIcon] = Sql.ObjectType.TypeImage16(type);

                    // Check if type is column, this is used to display the object column.
                    if (type == Sql.ObjectType.TypeEnum.Column)
                    {
                        m_IsColumn = true;
                    }

                    // Get the permissions and set check boxes.
                    row[colGrantCheckBox]     = string.Compare(row[colGrant].ToString(), Utility.Permissions.Grants.True, true) == 0;
                    row[colWithGrantCheckBox] = string.Compare(row[colWithGrant].ToString(), Utility.Permissions.Grants.True, true) == 0;
                    row[colDenyCheckBox]      = string.Compare(row[colDeny].ToString(), Utility.Permissions.Grants.True, true) == 0;

                    // Set the source information, if the permission is inherited.
                    // Only for server, database and schema.
                    string sourceName = string.Empty,
                           sourceType = string.Empty;
                    if (string.Compare(row[colInherited].ToString(), "Y", true) == 0)
                    {
                        sourceType = row[colSourceType].ToString();
                        if (string.Compare(sourceType, "Server", true) == 0 ||
                            string.Compare(sourceType, "Schema", true) == 0)
                        {
                            sourceName = row[colSourceName].ToString();
                            sourceType = row[colSourceType].ToString();
                        }
                        else if (string.Compare(sourceType, "Database Role", true) == 0)
                        {
                            sourceName = row[colSourceName].ToString();
                            sourceType = "Database";
                        }
                        else
                        {
                            sourceType = string.Empty;
                        }
                    }
                    row[colSourceName] = sourceName;
                    row[colSourceType] = sourceType;
                }
            }
            else
            {
                // Create table and configure columns.
                dt = new DataTable();
                dt.Columns.Add(colIcon);
                dt.Columns.Add(colGrantee);
                dt.Columns.Add(colPermission);
                dt.Columns.Add(colGrant);
                dt.Columns.Add(colGrantCheckBox, typeof(bool));
                dt.Columns.Add(colWithGrant);
                dt.Columns.Add(colWithGrantCheckBox, typeof(bool));
                dt.Columns.Add(colDeny);
                dt.Columns.Add(colDenyCheckBox, typeof(bool));
                dt.Columns.Add(colGrantor);
                dt.Columns.Add(colObjectName);
                dt.Columns.Add(colObjectTypeName);
                dt.Columns.Add(colObjectType);
                dt.Columns.Add(colInherited);
                dt.Columns.Add(colSourceName);
                dt.Columns.Add(colSourceType);
                dt.Columns.Add(colSourcePermission);
            }

            return(dt);
        }
コード例 #9
0
        private DataTable getGridDisplayTbl(DataSet ds)
        {
            // Fill the return data table.
            DataTable dt = null;
            if (ds != null && ds.Tables.Count > 0)
            {
                // Create data table object with selected columns.
                DataView dv = new DataView(ds.Tables[0]);
                dt = dv.ToTable("Permissions", true,
                                                new string[] { 
                                                colObjectName, colPermission, colGrant, colWithGrant, colDeny, colGrantor, //colGrantee, 
                                                colObjectType
                                            });

                // Add the icon column to the begining of the data table.
                dt.Columns.Add(colIcon, typeof(Image));
                dt.Columns[colIcon].SetOrdinal(IconIndex);

                // Add permission check boxes.
                dt.Columns.Add(colGrantCheckBox, typeof(bool));
                dt.Columns[colGrantCheckBox].SetOrdinal(GrantIndex);
                dt.Columns.Add(colWithGrantCheckBox, typeof(bool));
                dt.Columns[colWithGrantCheckBox].SetOrdinal(WithGrantIndex);
                dt.Columns.Add(colDenyCheckBox, typeof(bool));
                dt.Columns[colDenyCheckBox].SetOrdinal(DenyIndex);

                // Add object type.
                dt.Columns.Add(colObjectTypeName, typeof(string));
                dt.Columns[colObjectTypeName].SetOrdinal(ObjectTypeIndex);

                // Populate the icon column for each row.
                foreach (DataRow row in dt.Rows)
                {
                    //Get the type of object.
                    Sql.ObjectType.TypeEnum type = Sql.ObjectType.ToTypeEnum(row[colObjectType].ToString());
                    row[colIcon] = Sql.ObjectType.TypeImage16(type);

                    // Get the permissions and set check boxes.
                    row[colGrantCheckBox] = string.Compare(row[colGrant].ToString(), Utility.Permissions.Grants.True, true) == 0;
                    row[colWithGrantCheckBox] = string.Compare(row[colWithGrant].ToString(), Utility.Permissions.Grants.True, true) == 0;
                    row[colDenyCheckBox] = string.Compare(row[colDeny].ToString(), Utility.Permissions.Grants.True, true) == 0;

                    // Set the object type.
                    row[colObjectTypeName] = Sql.ObjectType.TypeName(type);
                }
            }
            else
            {
                // Create table and configure columns.
                dt = new DataTable();
                dt.Columns.Add(colIcon);
                dt.Columns.Add(colObjectName);
                dt.Columns.Add(colPermission);
                dt.Columns.Add(colGrant);
                dt.Columns.Add(colGrantCheckBox, typeof(bool));
                dt.Columns.Add(colWithGrant);
                dt.Columns.Add(colWithGrantCheckBox, typeof(bool));
                dt.Columns.Add(colDeny);
                dt.Columns.Add(colDenyCheckBox, typeof(bool));
                dt.Columns.Add(colGrantee);
                dt.Columns.Add(colGrantor);
                dt.Columns.Add(colObjectTypeName);
                dt.Columns.Add(colObjectType);
            }

            return dt;
        }