示例#1
0
        public void UpdateProcessPermissions(string userName)
        {
            // Create instance of the Permissions and ProcSetPermissions class
            Permissions        permissions     = new Permissions();
            ProcSetPermissions procPermissions = new ProcSetPermissions();

            // Set the required permission properties
            procPermissions.ProcSetID   = 1;
            procPermissions.UserName    = userName;
            procPermissions.Admin       = true;
            procPermissions.Start       = true;
            procPermissions.View        = false;
            procPermissions.ViewPart    = false;
            procPermissions.ServerEvent = false;

            // Add the ProcSetPermissions object to the Permissions object
            permissions.Add(procPermissions);

            // Multiple permissions can also be added
            // for other process sets
            ProcSetPermissions procPerms2 = new ProcSetPermissions();

            procPerms2.ProcSetID   = 2;
            procPerms2.UserName    = userName;
            procPerms2.Admin       = true;
            procPerms2.Start       = true;
            procPerms2.View        = false;
            procPerms2.ViewPart    = false;
            procPerms2.ServerEvent = false;

            permissions.Add(procPerms2);

            // Update the permissions
            bool updated = ManagementServer.UpdateUserPermissions(userName, permissions);
        }