{"id":1974,"date":"2012-04-01T06:00:07","date_gmt":"2012-04-01T06:00:07","guid":{"rendered":"http:\/\/enjoyasp.net\/?p=1974"},"modified":"2013-11-14T00:58:43","modified_gmt":"2013-11-14T00:58:43","slug":"mssql%e9%99%90%e5%88%b6ip%e6%89%80%e5%bc%95%e5%8f%91%e7%9a%84%e5%a4%b1%e8%af%af","status":"publish","type":"post","link":"https:\/\/enjoyasp.net\/index.php\/2012\/04\/01\/mssql%e9%99%90%e5%88%b6ip%e6%89%80%e5%bc%95%e5%8f%91%e7%9a%84%e5%a4%b1%e8%af%af\/","title":{"rendered":"MsSql\u9650\u5236IP\u6240\u5f15\u53d1\u7684\u5931\u8bef"},"content":{"rendered":"<p style=\"margin: 0px; padding: 8px 0px; line-height: 22px; text-align: justify; color: rgb(85, 85, 85); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);\">\n\t\u73b0\u9700\u8981\u9650\u5236MsSql\u4e0a\u7684\u767b\u5f55IP\uff0c\u9519\u8bef\u7684\u76f4\u63a5\u5c06\u4ee5\u4e0b\u8bed\u53e5\u6267\u884c\uff0c\u800c\u6ca1\u6709\u6539192.168.1.1\uff0c\u6b64\u65f6\u8fde\u63a5\u670d\u52a1\u5668\u5c31\u518d\u4e5f\u8fde\u63a5\u4e0d\u4e0a\uff0c\u9700\u8981\u7528DAC\u89e3\u51b3<br \/>\n\t\u6ce8\uff1a\u9650\u5236IP\u8bbf\u95ee\u6700\u597d\u7528IPsec\u7b56\u7565\u505a\uff0c\u4ee5\u514d\u5f71\u54cd\u6027\u80fd\u3002<br \/>\n\t<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\t1\uff0c\u5931\u8bef\u4ee3\u7801<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\tUSE master<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\tGO<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\tCREATE TRIGGER tr_LoginCheck<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\tON ALL SERVER<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\tFOR LOGON<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\tAS<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\tDECLARE @ClientHost varchar(100)<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\tSET @ClientHost= EVENTDATA().value(&lsquo;(\/EVENT_INSTANCE\/ClientHost)[1]&lsquo;, &lsquo;varchar(15)&rsquo;)<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\tIF ClientHost &lt;&gt;&rsquo;127.0.0.1&prime; AND ClientHost &lt;&gt; &lsquo;&lt;local machine&gt;&rsquo;<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\tROLLBACK TRAN<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\tGO<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\t&ndash;\u6b64\u89e6\u53d1\u5668\u53ef\u5728[\u670d\u52a1\u5668\u5bf9\u8c61 &#8211; \u89e6\u53d1\u5668\u4e0b]\u67e5\u770b<\/p>\n<p>\t\u53ef\u80fd\u8981\u7ed9\u8d26\u53f7\u5f00\u6743\u9650<\/p>\n<div>\n\tUSE [master]<\/div>\n<div>\n\tGO<\/div>\n<div>\n\tCREATE USER [myuser] FOR LOGIN [myuser]<\/div>\n<div>\n\tGO<\/div>\n<div>\n\t&#8211;grant select on ipcheck to myuser<\/div>\n<div>\n\t&nbsp;<\/div>\n<div>\n\tgrant VIEW SERVER STATE to myuser<br \/>\n\t&nbsp;<\/div>\n<p style=\"margin: 0px; padding: 8px 0px; line-height: 22px; text-align: justify; color: rgb(85, 85, 85); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);\">\n\t2\uff0c\u5931\u8bef\u540e\u767b\u5f55\u63d0\u793a\uff1alogin failed due to a TRIGGER<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\t3\uff0c\u89e3\u51b3\u65b9\u6848\uff1a<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\t\u5f00\u59cb-\u8fd0\u884c-cmd: sqlcmd -S LocalHost -d master -A<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\t1&gt; DROP TRIGGER tr_LoginCheck ON ALL SERVER<br style=\"margin: 0px; padding: 0px;\" \/><br \/>\n\t2&gt; GO<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u73b0\u9700\u8981\u9650\u5236MsSql\u4e0a\u7684\u767b\u5f55IP\uff0c\u9519\u8bef\u7684\u76f4\u63a5\u5c06\u4ee5\u4e0b\u8bed\u53e5\u6267\u884c\uff0c\u800c\u6ca1\u6709\u6539192.168.1.1\uff0c\u6b64\u65f6\u8fde\u63a5\u670d\u52a1\u5668\u5c31\u518d [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-1974","post","type-post","status-publish","format-standard","hentry","category-13"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/1974","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/comments?post=1974"}],"version-history":[{"count":0,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/1974\/revisions"}],"wp:attachment":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/media?parent=1974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/categories?post=1974"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/tags?post=1974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}