{"id":177,"date":"2019-09-30T22:31:01","date_gmt":"2019-09-30T19:31:01","guid":{"rendered":"http:\/\/www.potansif.com\/?p=177"},"modified":"2019-10-01T00:42:41","modified_gmt":"2019-09-30T21:42:41","slug":"sql-server-wan-ip-adresini-tespit-etmek","status":"publish","type":"post","link":"http:\/\/www.potansif.com\/?p=177","title":{"rendered":"SQL Server : WAN IP Adresini Tespit Etmek"},"content":{"rendered":"<p>Soru:<\/p>\n<p>Dinamik IP kullanan internete ba\u011fl\u0131 bir terminalde veya sunucuda kurulu olan SQL Server arac\u0131l\u0131\u011f\u0131yla WAN-IP adresini nas\u0131l tespit edebiliriz?<!--more--><\/p>\n<p><b>Cevap:<\/b><\/p>\n<p>Anlad\u0131\u011f\u0131m kadar\u0131yla dinamik IP kullanan bir network&#8217;deki SQL Server&#8217;a eri\u015fmek istiyorsunuz ve bunun i\u00e7in IP&#8217;nin g\u00fcncel de\u011ferini \u00f6\u011frenmek niyetindesiniz, do\u011fru mu?<\/p>\n<p>Durum bundan ibaret ise a\u015fa\u011f\u0131daki kodlarla bunu yapabilirsiniz. Fakat dikkat etmeniz gereken baz\u0131 noktalar var, bu noktalara dikkat etmez ve kodun arkas\u0131n\u0131 toplamazsan\u0131z ciddi g\u00fcvenlik a\u00e7\u0131klar\u0131na da sebep olabilirsiniz. O nedenle a\u015fa\u011f\u0131da \u00f6rne\u011fini verdi\u011fim kodu iyice hazmetmeden kullanmaman\u0131z\u0131 tavsiye ederim.<\/p>\n<pre><code>sp_configure 'show advanced options', 1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--&gt;&nbsp; SQL Server'in geli\u015fmi\u015f se\u00e7eneklerini kullanabilmek i\u00e7in ilgili kilidi A\u00c7IYORUZ\nreconfigure with override&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--&gt;&nbsp; SQL Server'i son duruma g\u00f6re yeniden konfig\u00fcre ediyoruz.\nGO\n\nsp_configure 'Ole Automation Procedures', 1&nbsp; &nbsp; &nbsp; &nbsp;--&gt;&nbsp; SQL Server'in OLE Otomasyon nesnelerini kullanabilmesi i\u00e7in ilgili kilidi A\u00c7IYORUZ\nreconfigure with override&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--&gt;&nbsp; SQL Server'i son duruma g\u00f6re yeniden konfig\u00fcre ediyoruz.\nGO\n\nDECLARE&nbsp; @SONUC&nbsp; VARCHAR(50)\n&nbsp; &nbsp; &nbsp; ,&nbsp; @HATA&nbsp; &nbsp; INT\n&nbsp; &nbsp; &nbsp; ,&nbsp; @CEVAP&nbsp; INT\n\nEXEC @HATA&nbsp; = sp_OACreate 'MSXML2.ServerXMLHTTP'&nbsp; --&gt; OLE Otomasyon nesnesi \u00fcretiyoruz,\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , @CEVAP OUT&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt;&nbsp; metodun return de\u011ferini @CEVAP de\u011fi\u015fkenine al\u0131yoruz...\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;\nIF (@HATA &lt;&gt; 0) RAISERROR('HTTP Ba\u011flant\u0131s\u0131 a\u00e7\u0131lamad\u0131.', 10, 1);&nbsp; --&gt; Cevap olarak Durum koduna bak\u0131yoruz, 0'dan farkl\u0131ysa hata kodu olu\u015fmu\u015f demektir...\n\nEXEC @HATA&nbsp; = sp_OAMethod @CEVAP&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt; AYNI NESNEN\u0130N\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , 'open'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt;&nbsp; OPEN metodunu \u00e7al\u0131\u015ft\u0131r\u0131p parametreleri devam\u0131nda veriyoruz.\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , NULL&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt; Bundan sonras\u0131 \u00e7a\u011f\u0131rd\u0131\u011f\u0131m\u0131z metodun parametrelerine g\u00f6re de\u011fi\u015febiliyor\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , 'POST'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt; Ayr\u0131nt\u0131lar i\u00e7in https:\/\/docs.microsoft.com\/en-us\/sql\/relational-databases\/system-stored-procedures\/sp-oamethod-transact-sql?view=sql-server-2017&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , 'http:\/\/www.dubaron.com\/myip'&nbsp; &nbsp; &nbsp; &nbsp;--&gt; IP adresimizi bize s\u00f6yleyen bir web sitesi. sonu\u00e7 sadece IP adresi oldu\u011fu i\u00e7in parse etme ihtiyac\u0131 olmuyor...\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , 'false'\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;\nEXEC @HATA&nbsp; = sp_OAMethod @CEVAP&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt;&nbsp; AYNI NESNEN\u0130N\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , 'send'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt; SEND metodunu \u00e7al\u0131\u015ft\u0131r\u0131yoruz...\n\nEXEC @HATA = sp_OAGetProperty @CEVAP&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt;&nbsp; AYNI NESNEN\u0130N\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , 'responseText'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt;&nbsp; \"responseText\" field'ini \"OKUYORUZ\"\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , @SONUC OUT&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt; okunan fieldin de\u011ferini \/ i\u00e7eri\u011fini @SONUC de\u011fi\u015fkenine al\u0131yoruz\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;\n\nSELECT @SONUC as WanIpAdresi;\nGO\n\nsp_configure 'Ole Automation Procedures', 0&nbsp; &nbsp; &nbsp; &nbsp;--&gt;&nbsp; SQL Server'in OLE Otomasyon nesnelerini kullanabilmesi i\u00e7in ilgili kilidi KAPATIYORUZ\nreconfigure with override&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--&gt;&nbsp; SQL Server'i son duruma g\u00f6re yeniden konfig\u00fcre ediyoruz.\nGO\n\nsp_configure 'show advanced options', 0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--&gt;&nbsp; SQL Server'in geli\u015fmi\u015f se\u00e7eneklerini kullanabilmek i\u00e7in ilgili kilidi KAPATIYORUZ\nreconfigure with override&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--&gt;&nbsp; SQL Server'i son duruma g\u00f6re yeniden konfig\u00fcre ediyoruz.\nGO<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Dinamik IP kullanan internete ba\u011fl\u0131 bir terminalde veya sunucuda kurulu olan SQL Server arac\u0131l\u0131\u011f\u0131yla WAN-IP adresini nas\u0131l tespit edebiliriz?<\/p>\n","protected":false},"author":1,"featured_media":200,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[54,52,53,11,44,7,55],"class_list":["post-177","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-automation","tag-dynamic-ip","tag-ole","tag-programlama","tag-soru-cevap","tag-sql-server","tag-wan-ip"],"_links":{"self":[{"href":"http:\/\/www.potansif.com\/index.php?rest_route=\/wp\/v2\/posts\/177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.potansif.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.potansif.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.potansif.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.potansif.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=177"}],"version-history":[{"count":1,"href":"http:\/\/www.potansif.com\/index.php?rest_route=\/wp\/v2\/posts\/177\/revisions"}],"predecessor-version":[{"id":184,"href":"http:\/\/www.potansif.com\/index.php?rest_route=\/wp\/v2\/posts\/177\/revisions\/184"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.potansif.com\/index.php?rest_route=\/wp\/v2\/media\/200"}],"wp:attachment":[{"href":"http:\/\/www.potansif.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.potansif.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=177"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.potansif.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}