Рассмотрим, например, ситуацию, когда хранимая процедура по входному параметру паролю брала бы его MD5 значение и заносила полученное значение в таблицу.
Такая ситуация может возникнуть при регистрации пользователей, когда в таблице находятся не реальные пароли, а их MD5 значения.
Возникает вопрос - можно ли функционал по взятию MD5 значений паролей перенести в хранимую процедуру, если существует COM-объект, который генерит хэш-значения MD5 ?
Конечно, эту процедуру можно реализовать в приложении через простой вызов COM-объекта, но мы рассмотрим как это можно сделать в Transact-SQL.
В качестве COM-объекта возьмем ActiveX-компонент CryptLib, который можно взять на данном сайте activex/activex/more.shtml#cryptlib и зарегистрировать в реестре стандартно через regsvr32.
Далее воспользуемся системными процедурами SQL Server, которые позволяют работать с COM-объектами:
sp_OACreate
sp_OAMethod
sp_OADestroy
sp_OAGetErrorInfo
Для запуска этих системных процедур пользователь, от имени которого будет запускаться наша процедура, должен входить в роль sysadmin.
Текст процедуры InsertMD5Value:
CREATE PROCEDURE dbo.InsertMD5Value @Login Varchar(50), @Password Varchar(50) AS DECLARE @object int DECLARE @hr Int DECLARE @md5_hash varchar(255) DECLARE @src varchar(255), @desc varchar(255) SET NOCOUNT ON EXEC @hr = sp_OACreate 'CryptLib.MD5', @object OUT IF @hr <> 0 -- Сообщение об ошибке BEGIN
EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc GOTO END_FINAL END ELSE BEGIN EXEC @hr = sp_OAMethod @object, 'Crypt', @md5_hash OUT, @Password IF @hr <> 0 GOTO CLEANUP ELSE PRINT @md5_hash -- для примера просто печатаем MD5 значение. -- здесь можно делать вставку полученного MD5 значения в таблицу, -- предварительно сделав проверку на существование в таблице значения -- из переданного параметра @Login -- INSERT INTO UsersReg (Login, Passwd) VALUES (@Login, @Password) END CLEANUP: IF @hr <> 0 BEGIN EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc END BEGIN EXEC @hr = sp_OADestroy @object IF @hr <> 0 BEGIN EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc END END END_FINAL: RETURN
|
Для запуска этой хранимой процедуры достаточно просто выполнить
EXEC dbo.InsertMD5Value 'user1', 'test'
Христофоров Юрий
Другие работы по теме:
Работа с регулярными выражениями в SQL Server
В SQL Server 7/2000 нет встроенной поддержки работы с регулярными выражениями. Но SQL Server похволяет работать с COM-объектами. В VBScript (библиотека vbscript.dll) есть специальный объект для работы с регулярными выражениями - RegExp.
LAN Server 4.0
Общая характеристика. Управление сервером LAN Server 4.0. Совместимость с NetWare.
Использование программы Access в книжном магазине
Характеристика технических возможностей и функций программы Access. Методы построения запросов форм и отчетов, позволяющих получать следующую информацию: какие книги по тематике и автору имеются в магазине, подсчет выручки от реализации за текущий месяц.
MS SQL server6.5
הקדמה כשמדברים על MS SQL Server אי אפשר להתעלם מהעובדה שהמצאת מכונות
Upload файлов с уникальными именами в ASP.NET
Христофоров Юрий Задача: необходимо загружать файлы в папку upload на сервере с уникальными именами. Т.е. при загрузке двух файлов с одинаковыми именами они должны сохраняться под уникальными именами и не перезаписывать друг друга. В ASP.NET эта задача легко решается с помощью класса Guid. Т.о. файл будет сохранен например под именем fe008e1a-f07c-4263-8dc4-67f042a8cbdb_valley.jpg.
Vicky Essay Research Paper Maniac Soft Animated
Vicky Essay, Research Paper Maniac Soft Animated GIF Viewer AGV 1.0 ======================================= Hi there, thank you for using AGV 1.0. My name’s Christian “Maniac” Stauffer from Maniac Soft.
Log Shipping Essay Research Paper The concept
Log Shipping Essay, Research Paper The concept of standby servers is not a new one. It has been around a long time and been used by many DBAs. Traditionally, using a standby server for failover has involved manually making database and log backups on the production server and then restoring them to the standby server on a regular basis.
Tennis 2 Essay Research Paper As we
Tennis 2 Essay, Research Paper As we all know, America is a nation of sports enthusiasts. Most Americans participate is some kind of sporting event, either as a spectator or as a competitor. In the pantheon of great American sports, there is one that stands out. It has been called the great American pastime.
Situation Essay Research Paper The situation I
Situation Essay, Research Paper The situation I would like to explain happened fairly recently. I have accepted a position with a National Bank as one of their E-mail Server Administrators. An acquaintance of mine (Don) told me about the position and took my resume to his supervisor. He is not someone I call a friend because we do not do any activities together nor do our wives do things together.
Skills Of Table Tennis Essay Research Paper
Table tennis is played on thick wooden or composite wood, plastic and even metal varieties table. The surface of the table should have a mat finish and it is usually dark green or blue. The table is 274 cm in length, 152.5 cm in width, and 76 cm in height.
Personal Computers And Laptop Computers Essay Research
Paper The two types of computers that are the most common people use are the Personal computer, and the Laptop computer. Most people would say that there is not that much difference between the two, but they have no idea how wrong they are.
How To Get A Twenty Essay Research
Paper How to Get Twenty There is a lot more to waiting tables than just serving food and drinks; customer relations is the biggest part of being a good server, because the majority of your income relies on how much your customers tip. To ensure that you receive a good tip you must do a number of things. Most importantly you must be polite, and of course remember that no matter what, the customer is always right.
Queuing Analysis Essay Research Paper email jjacksonjaguarirmiamiedutitle
Queuing Analysis Essay, Research Paper email: jjackson@jaguar.ir.miami.edutitle: Queuing AnalysisQueuing analysis is the study of waiting lines, and the goal of queuing analysis is to minimize total costs of a business; that is, to minimize both the costs of maintaining the ability of providing service (i.e. cashiers in a supermarket), and the costs of customer waiting.
Denial Of Service Attacks Essay Research Paper
Denial of Service Attacks Definition: Denial of Service. A cracker attack that overloads a server to the point that it no longer responds or shuts down completely. To flood a network or individual server with huge amounts of data packets.
Cgi Scripts Essay Research Paper CGI Scripts
Cgi Scripts Essay, Research Paper CGI Scripts Must have Internet service provider that will allow you to run CGI scripts. You should really have telnet access to your account, too
Dell Company Essay Research Paper 1 One
Dell Company Essay, Research Paper 1. One force that is driving the strategic direction of Dell is the server market. Dell is currently fourth in server sales. Dell has also moved into the international market, including various web pages for different countries, each with separate languages. Computers are also manufactured in foreign markets to cut cost.
Domain Name Server Essay Research Paper The
Domain Name Server Essay, Research Paper The Domain System Network software generally needs a 32-bit Internet address in order to open a connection or send a datagram. However users prefer to deal with computer names rather than numbers.
All Servers Essay Research Paper All Servers
All Servers Essay, Research Paper All Servers: All condiments on your tables cleaned and filled completely Tables completely set properly ready to go for the next shift. This includes napkins, flatware, and plates. Station 1 Server: Straighten front coffee station Empty coffee machine and clean throughly Clean coffee pots with water, salt, lemon, and ice then let stand over night.
A Personal Situation Essay Research Paper A
A Personal Situation Essay, Research Paper A PERSONAL SITUATION The situation I would like to explain happened approximately over a year ago. I accepted a position with a company as one of their e-mail server. An acquaintance of mine (John) told me about the job and took my resume to his supervisor. I did not refer to him as a friend because at the time we did not do any activities together outside of work, nor did our spouses.
System Administration And Me Essay Research Paper
System Administration and Me What is system administration? System administration is basically adding and configuring new workstations, setting up user accounts, installing system-wide software, performing procedures to prevent the spread of viruses, and allocating mass storage type. While there are a lot more things that make up the job description of most system administrators, these are the ones that I’ll be touching on in this report.
The Game Of Tennis Essay Research Paper
ennis is a game which opposing players-one or two on each side-use rackets to hit a ball back and forth over a net. The game is played on a flat surface called a court. Each player tries to score points by hitting the ball so that the opposing player or players cannot return it over the net and inside the court.
Mobile Alerts Essay Research Paper Mobile Alerts
Mobile Alerts Essay, Research Paper Mobile Alerts – Concept Paper. What is Mobile Alert? Mobile Alert is the text message (SMS) sent to a mobile phone as a result of occurrence of an event for which the mobile user has registered the request for getting the notification.
Cold Fusion Essay Research Paper Allaire
Cold Fusion Essay, Research Paper Allaire’s ColdFusion studio and server package allows web developers to create database driven applications. ColdFusion is server side scripting that utilizes Microsoft ODBC drivers to access system databases. This allows ColdFusion to produce dynamic pages generated real time by the server.
Computer Tech Essay Research Paper Common Network
Computer Tech Essay, Research Paper Common Network Architectures There are many different types of networks used today that could be evaluated. I would like to take a brief look at three main types of networks, the host-based network, the client-based network, and the client-server network. I would like to look at both the advantages and disadvantages of each type.
Home Computer Network Essay Research Paper Have
Home Computer Network Essay, Research Paper Have you ever needed to have more than one home computer for you and your family? Do you have two or more computers, but need to copy and/or share files and/or programs between them, but you don t know how? Do all of your computers need Internet access, but you don t want to have a phone line installed for each of them? Well, you can do all of this.
What Is A Computer Network Essay Research
Paper What is a computer network? In simple terms, a computer network is a group of connected computers that allow the sharing of information and equipment. The most ordinary network is made up of two computers connected by some kind of cable in order to exchange information more quickly and efficiently. A standalone computer is very useful to many businesses, but without a network, those businesses would have to spend twice the amount of money then they would have to by having a network.
Tennis Essay Research Paper Tennis PaperTennis is
Tennis Essay, Research Paper Tennis Paper Tennis is a gamr for everyone. It is fun and a form of good exercise. In this paper you will get the very basic understanding of the game of tennis. By the end og the paper you will know the rulse, proper equipment, size of cout you play on and the basic edici
Internet Essay Research Paper Unfortunately there
Internet Essay, Research Paper Unfortunately, there’s a lot to worry about. There are security risks that affect Web servers, the local area networks that host Web sites, and even innocent users of Web browsers.
Lock Outs In Sql Server Essay Research
Paper Lock Outs in SQL Server If you lock yourself out of SQL Server without being able to log on with a sysadmin login, you don’t have to reinstall SQL Server. To access SQL Server, you need to use the registry key for SQL Server 2000 and SQL Server 7.0 that determines the authentication mode of SQL Server.