Форум: "Система";
Текущий архив: 2002.10.24;
Скачать: [xml.tar.bz2];
ВнизПрава на использование принтера Найти похожие ветки
← →
Vlad2 (2002-08-19 06:29) [0]Здравствуйте !
Подскажите, пожалуйста, как
ограничить доступ к принтеру только из приложения, запущенного на данной станции. Принтер локальный и подключен к данной станции.
← →
Севостьянов Игорь (2002-08-19 13:02) [1]Думаю, это возможно только в WinNT платформенной ОС
Windows 95/98: Unsupported.
SetPrinter
The SetPrinter function sets the data for a specified printer or sets the state of the specified printer by pausing printing, resuming printing, or clearing all print jobs.
BOOL SetPrinter(
HANDLE hPrinter, // handle to printer object
DWORD Level, // information level
LPBYTE pPrinter, // printer data buffer
DWORD Command // printer-state command
);
Parameters
hPrinter
[in] Handle to the printer. Use the OpenPrinter or AddPrinter function to retrieve a printer handle.
Level
[in] Specifies the type of data that the function stores into the buffer pointed to by pPrinter. If the Command parameter is not equal to zero, the Level parameter must be zero.
Windows 95: This value can be 0, 2, 3, 4, or 5.
Windows NT/Windows 2000: This value can be 0, 2, 3, 4, 5, 7, 8, or 9.
pPrinter
[in] Pointer to a buffer containing data to set for the printer, or containing information for the command specified by the Command parameter. The type of data in the buffer is determined by the value of Level. Level Structure
0 If the Command parameter is PRINTER_CONTROL_SET_STATUS, pPrinter must contain a DWORD value that specifies the new printer status to set. For a list of the possible status values, see the Status member of the PRINTER_INFO_2 structure. Note that PRINTER_STATUS_PAUSED and PRINTER_STATUS_PENDING_DELETION are not valid status values to set.
If Level is 0, but the Command parameter is not PRINTER_CONTROL_SET_STATUS, pPrinter must be NULL.
2 A PRINTER_INFO_2 structure containing detailed information about the printer.
3 Windows NT/ 2000: A PRINTER_INFO_3 structure containing the printer"s security information.
4 Windows NT/ 2000: A PRINTER_INFO_4 structure containing minimal printer information, including the name of the printer, the name of the server, and whether the printer is remote or local.
5 A PRINTER_INFO_5 structure containing printer information such as printer attributes and time-out settings.
7 Windows 2000: A PRINTER_INFO_7 structure. The dwAction member of this structure indicates whether SetPrinter should publish, unpublish, re-publish, or update the printer"s data in the directory service.
8 Windows 2000: A PRINTER_INFO_8 structure specifying the global default printer settings.
9 Windows 2000: A PRINTER_INFO_9 structure specifying the per-user default printer settings.
Command
[in] Specifies the action performed by the SetPrinter function.
If the Level parameter is nonzero, Command must be zero. In this case, the printer retains its current state and the function reconfigures the printer data as specified by the Level and pPrinter parameters.
If the Level parameter is zero, Command can be one of the following values to set the state of the printer. Value Meaning
PRINTER_CONTROL_PAUSE Pauses the printer.
PRINTER_CONTROL_PURGE Deletes all print jobs in the printer.
PRINTER_CONTROL_RESUME Resumes a paused printer.
PRINTER_CONTROL_SET_STATUS Sets the printer status. The pPrinter parameter is a pointer to a DWORD that specifies the new printer status.
Return Values
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Windows 2000: If Level is 7 and the publish action failed, SetPrinter returns ERROR_IO_PENDING and attempts to complete the action in the background. If Level is 7 and the update action failed, SetPrinter returns ERROR_FILE_NOT_FOUND.
← →
Севостьянов Игорь (2002-08-19 13:02) [2]
Remarks
To modify the current printer settings, call the GetPrinter function to retrieve the current settings into a PRINTER_INFO_2 structure, modify the members of that structure as necessary, and then call SetPrinter.
The SetPrinter function ignores the pServerName, AveragePPM, Status, and cJobs members of a PRINTER_INFO_2 structure.
Pausing a printer suspends scheduling of all print jobs for that printer, except for the one print job that may be currently printing. Print jobs can be submitted to a paused printer, but no jobs will be scheduled to print on that printer until printing is resumed. If a printer is cleared, all print jobs for that printer are deleted, except for the current print job.
If you use SetPrinter to modify the default DEVMODE structure for a printer (globally setting the printer defaults), you must first call the DocumentProperties function to validate the DEVMODE structure.
Windows NT/Windows 2000: For the PRINTER_INFO_2 and PRINTER_INFO_3 structures that contain a pointer to a security descriptor, the function can set only those components of the security descriptor that the caller has permission to modify. To set particular security descriptor components, you must specify the necessary access rights when you call the OpenPrinter function to retrieve a handle to the printer. The following table shows the access rights required to modify the various security descriptor components.
Access permission Security descriptor component
WRITE_OWNER Owner
Primary proup
WRITE_DAC Discretionary access-control list (DACL)
ACCESS_SYSTEM_SECURITY System access-control list (SACL)
If the security descriptor contains a component that the caller does not have the access right to modify, SetPrinter fails. Those components of a security descriptor that you don"t want to modify should be NULL or not be present, as appropriate. If you do not want to modify the security descriptor, and are calling SetPrinter with a PRINTER_INFO_2 structure, set the pSecurityDescriptor member of that structure to NULL.
Windows 2000: You can use level 7 with the PRINTER_INFO_7 structure to publish, unpublish, or update directory service data for the printer. The directory service data for a printer includes all the data stored under the SPLDS_* keys by calls to the SetPrinterDataEx function for the printer. Before calling SetPrinter, set the pszObjectGUID member of PRINTER_INFO_7 to NULL and set the dwAction member to one of the following values.
Value Description
DSPRINT_PUBLISH Publishes the directory service data.
DSPRINT_REPUBLISH The directory service data for the printer is unpublished and then published again, refreshing all properties in the published printer. Re-publishing also changes the GUID of the published printer. Use this value if you suspect the printer"s published data has been corrupted.
DSPRINT_UNPUBLISH Unpublishes the directory service data.
DSPRINT_UPDATE Updates the directory service data. This is the same as DSPRINT_PUBLISH, except that SetPrinter fails with ERROR_FILE_NOT_FOUND if the printer is not already published.
Use DSPRINT_UPDATE to update published properties but not force publishing. Printer drivers should always use DSPRINT_UPDATE rather than DSPRINT_PUBLISH.
DSPRINT_PENDING is not a valid dwAction value for SetPrinter.
Windows 95: SetPrinter does not update the pShareName member in the PRINTER_INFO_2 structure.
You cannot call SetPrinter from a Windows 95 computer to set the data for a Windows NT printer using the printer"s UNC name.
Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winspool.h; include Windows.h.
Library: Use Winspool.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
See Also
Printing and Print Spooler Overview, Printing and Print Spooler Functions, AddPrinter, GetPrinter, OpenPrinter, PRINTER_INFO_2, PRINTER_INFO_3, PRINTER_INFO_4, PRINTER_INFO_5, PRINTER_INFO_6, PRINTER_INFO_7, PRINTER_INFO_8, PRINTER_INFO_9, SetPrinterDataEx
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winspool.h; include Windows.h.
Library: Use Winspool.lib.
See Also
Printing and Print Spooler Overview, Printing and Print Spooler Functions, AddPrinter, GetPrinter, OpenPrinter, PRINTER_INFO_2, PRINTER_INFO_3, PRINTER_INFO_4, PRINTER_INFO_5, PRINTER_INFO_6, PRINTER_INFO_7, PRINTER_INFO_8, PRINTER_INFO_9, SetPrinterDataEx
← →
Севостьянов Игорь (2002-08-19 13:03) [3]
Platform SDK: Windows GDI
PRINTER_INFO_3
The PRINTER_INFO_3 structure specifies printer security information.
typedef struct _PRINTER_INFO_3 {
PSECURITY_DESCRIPTOR pSecurityDescriptor;
} PRINTER_INFO_3, *PPRINTER_INFO_3;
Members
pSecurityDescriptor
Pointer to a SECURITY_DESCRIPTOR structure that specifies a printer"s security information.
Remarks
The PRINTER_INFO_3 structure lets an application get and set a printer"s security descriptor. The caller may do so even if it lacks specific printer permissions, as long as it has the standard rights described in SetPrinter and GetPrinter. Thus, an application may temporarily deny all access to a printer, while allowing the owner of the printer to have access to the printer"s discretionary ACL.
Requirements
Windows NT/2000: Requires Windows NT 3.5 or later.
Windows 95/98: Unsupported.
Header: Declared in Winspool.h; include Windows.h.
See Also
Printing and Print Spooler Overview, Printing and Print Spooler Structures, SetPrinter, GetPrinter, PRINTER_INFO_1, PRINTER_INFO_2, PRINTER_INFO_4, SECURITY_DESCRIPTOR
← →
Севостьянов Игорь (2002-08-19 13:03) [4]
SECURITY_DESCRIPTOR
The SECURITY_DESCRIPTOR structure contains the security information associated with an object. Applications use this structure to set and query an object"s security status.
Applications are not to modify the SECURITY_DESCRIPTOR structure directly. For creating and manipulating a security descriptor, use the functions listed in the See Also section.
typedef struct _SECURITY_DESCRIPTOR {
BYTE Revision;
BYTE Sbz1;
SECURITY_DESCRIPTOR_CONTROL Control;
PSID Owner;
PSID Group;
PACL Sacl;
PACL Dacl;
} SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
typedef PVOID PSECURITY_DESCRIPTOR;
Remarks
A security descriptor includes information that specifies the following components of an object"s security:
An owner (SID)
A primary group (SID)
A discretionary ACL
A system ACL
Qualifiers for the preceding items
Security descriptors use access-control lists (ACLs) and security identifiers (SIDs) to specify the information in this list.
A security descriptor can be in absolute or self-relative form. In self-relative form, all members of the structure are located contiguously in memory. In absolute form, the structure only contains pointers to the members.
Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Header: Declared in Winnt.h; include Windows.h.
See Also
Access Control Overview, Access Control Structures, GetSecurityDescriptorControl, GetSecurityDescriptorDacl, GetSecurityDescriptorGroup, GetSecurityDescriptorLength, GetSecurityDescriptorOwner, GetSecurityDescriptorRMControl, GetSecurityDescriptorSacl, InitializeSecurityDescriptor, IsValidSecurityDescriptor, SetSecurityDescriptorDacl, SetSecurityDescriptorGroup, SetSecurityDescriptorOwner, SetSecurityDescriptorRMControl, SetSecurityDescriptorSacl
← →
Vlad2 (2002-08-19 13:38) [5]to Севостьянов Игорь
Спасибо !
Попробую разобраться.
Страницы: 1 вся ветка
Форум: "Система";
Текущий архив: 2002.10.24;
Скачать: [xml.tar.bz2];
Память: 0.48 MB
Время: 0.009 c