2012/07/27

SQL Server 2008 R2 서비스 팩 2 다운로드

Microsoft® SQL Server® 2008 R2 서비스 팩 2 다운로드가 지금 바로 가능! 7월 26일자로 배포 시작.  

  SQL Server® 2008 R2 서비스 팩 2
  http://www.microsoft.com/ko-kr/download/details.aspx?id=30437

  Microsoft® SQL Server® 2008 R2 SP2 - Express Edition
http://www.microsoft.com/ko-kr/download/details.aspx?id=30438

  Microsoft® SQL Server® 2008 R2 SP2 기능 팩
  http://www.microsoft.com/ko-kr/download/details.aspx?id=30440



2012/07/26

IIS 8, SNI(서버 이름 표시) 지원

기존에 IIS 에서는 기본으로 SSL 에 대한 호스트 기반으로 작동하지 않고 포트 기반으로 작동 함.  바인딩 자체가 0.0.0.0:443 이렇게 되어서, 기본 SSL 포트를 통해서 여러 SSL 도메인을 사용할수가 없었음. 하지만, IIS 8로 업그레이드 되면서 SNI 기능을 지원하게 됨. (위키피디아 SNI) (but,  클라이언트중에 Windows XP  및 몇몇 웹브라우져는 지원하지 않음)

 

 호스트 이름:포트 : www.comodossl.co.kr:443

 인증서 해시 : 81605a6d1e4b6ab7fc5d6119b26c4ca55d80f65d 응용 프로그램 ID : {4dc3e181-e14b-4a21-b022-59fc669b0914}

 인증서 저장소 이름: WebHosting

 클라이언트 인증서 해지 확인 : Enabled
 캐시된 클라이언트 인증서만 사용하여 해지 확인 : Disabled
 사용 확인 : Enabled
 해지 유효 시간 : 0
 URL 검색 제한 시간 : 0
 Ctl 식별자 : (null)
 Ctl 저장소 이름 : (null)
 DS 매퍼 사용 : Disabled
 클라이언트 인증서 협상 : Disabled

 물론, 기존 IIS 6 등에서도 아래와 같은 방법으로 동일 SSL 포트가 사용 가능하지만,.

 cscript.exe adsutil.vbs set /w3svc/<replace with your site id>/SecureBindings ":443:www.domain1.com" 위의 경우 WildcardSSL 또는 MultiDomainSSL 인 경우에만 적용이 가능

iis8-ssl-sni.png

2012/07/23

SQL CLR 을 통한 공유 폴더 파일 복사 예

SQL Server CLR 은 닷넷 프레임워크 런타임을 통합하여  SQL Server 의 확장성을 매우 높혀주는 방식으로,. 자세한 사항은 http://msdn.microsoft.com/ko-kr/library/ms131102 를 참조. 아래 예제 코드는 SQL Server 에서 공유 폴더의  파일 정보를 가져오는 사용자 정의 함수 간단 코드.


using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Security.Principal;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Permissions;

public partial class UserDefinedFunctions {
    [DllImport("advapi32.dll", SetLastError = true)]
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")] 

public static extern bool LogonUser(string lpszUsername,
        string lpszDomain,
        string lpszPassword,
        int dwLogonType,
        int dwLogonProvider,
        ref IntPtr phToken);

    [Microsoft.SqlServer.Server.SqlFunction(DataAccess = DataAccessKind.Read)] 
public static SqlString yeonpilTestFunction(SqlString LogonName,
        SqlString DomainName,
        SqlString LogonPassword,
        SqlString LocalPathFile,
        SqlString RemoteUNCFile) {
        // ALTER DATABASE CLRTest SET TRUSTWORTHY ON 
        IntPtr token = IntPtr.Zero;
        bool valid = LogonUser((string) LogonName, (string) DomainName,
            (string) LogonPassword, 2, 0, ref token);

        if (valid) {
            using(WindowsImpersonationContext context = WindowsIdentity.Impersonate(token)) {
                File.Copy((string) LocalPathFile, (string) RemoteUNCFile, true);
                context.Undo();
            }
        }

        return new SqlString("Success");
    }
};


간단하며,. 공유 폴더에 접근 하려면 원격지 서버에 대한 인증을 해야 하는데, 레거시 API  참조. 인증을 통과한 후에는 일반적인 닷넷 코드를 그대로 사용 하면 되며 SQL 에서 사용자 정의 함수의 데이터 형에 맞게 처리만 해주면 완료.

 배포는,  VS.NET 의 배포를 하게 되면 원격지 SQL 서버에 배포가 자동으로 됨. 하지만 자동으로 배포시에는 SQL 서버에서 권한 문제로 설정값 편집이 되지 않으므로, SQL 쿼리 스트립트를 생성하여 서버에서 실행하여 등록하는 것이 좋음.

CREATE FUNCTION [dbo].[yeonpilFunction](@LogonName [nvarchar](4000), @DomainName [nvarchar](4000), @LogonPassword [nvarchar](4000), @LocalPathFile [nvarchar](4000), @RemoteUNCFile [nvarchar](4000)) RETURNS [nvarchar](4000) WITH EXECUTE AS CALLER AS EXTERNAL NAME [SqlServerCLRTest].[UserDefinedFunctions].[yeonpilFunction]
 GO

EXEC sys.sp_addextendedproperty @name=N'SqlAssemblyFile', @value=N'Function1.cs' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'FUNCTION',@level1name=N'yeonpilFunction'
 GO

 EXEC sys.sp_addextendedproperty @name=N'SqlAssemblyFileLine', @value=N'17' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'FUNCTION',@level1name=N'yeonpilFunction'
 GO

위와 같은 함수를 생성후에 아래와 같은 방식으로 사용자 쿼리문에서 호출 하여 사용

exec yeonpilFunction  'id','domain', 'pwd','d:\test11.txt','\\원격지서버\d$\saved.txt'


Symantec Endpoint Protection(SEP) Manager Password Reset

C:\Program Files (x86)\Symantec\Symantec Endpoint Protection Manager\Tools 의 resetpass.bat 배치 파일을 실행하면 초기화 됨.
@echo off setlocalset CATALINA_HOME=%CD%\..\tomcat set JAVA_HOME=%CD%\..\jdk"%JAVA_HOME%\bin\java.exe" -Xms64m -Xmx256m -XX:MinHeapFreeRatio=30 -XX:MaxHeapFreeRatio=40 -classpath "%CD%\..\bin\inst.jar;%CD%\..\bin\inst-res.jar" -Dcatalina.home="%CATALINA_HOME%" -Djava.library.path="%CATALINA_HOME%\bin" com.sygate.scm.tools.DatabaseFrame setpassword admin admin endlocal
 

2012/07/20

WindowsUpdateClient / ID: 20

로그 이름: System 원본: Microsoft-Windows-WindowsUpdateClient 이벤트 ID: 20 작업 범주: Windows Update 에이전트 수준: 오류 키워드: 실패,설치 사용자: SYSTEM 설명: 설치 실패: 0x8024d00e 오류 때문에 Windows에서 다음 업데이트를 설치하지 못했습니다. Windows Update Core. 0x8024d00e => WU_E_SETUP_REBOOTREQUIRED  리붓팅 필요 Windows Update Agent setup package requires a reboot to complete installation.

2012/07/19

원격 데스크톱 클라이언트 6.0 네트워크 수준 인증 오류

환경 : Windows Xp Professional SP3 메시지: 사용자 컴퓨터에서 지원하지 않는 네트워크 수준 인증이 원격 컴퓨터에 필요합니다.

 원격 데스크톱 클라이언트 6.0 으로, 터미널 서버에 접근하는 경우 네트워크 인증 호환성 문제로 위와 같은 메시지가 출력될수 있음. (네트워크 수준 인증, http://technet.microsoft.com/ko-kr/library/cc732713(v=ws.10))

 Windows Server 2008 / R2 에서는 2가지 옵션별 선택이 가능하지만, Windows Server 2012 에서는 허용시에, "네트워크 수준 인증을 사용하여 원격 데스크톱을 실행하는 컴퓨터에서만 연결 허용" 이 기본값으로 설정 됨. 물론 허용 설정하면 예전 인증 방식을 통해서 가능함. 그렇지만 권장 사항은 아님.



 Windows XP SP3 에서는 기본값으로 Credssp 보안 공급자가 활성화 되어 있지 않으므로 직접 허용 설정을 해줘야 함.(레지스트 수정 필요)

 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa] "Authentication Packages"=hex(7):6d,00,73,00,76,00,31,00,5f,00,30,00,00,00,00,00 kerberos msv1_0 schannel wdigest tspkg (추가)

 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders] "SecurityProviders"="msapsspc.dll, schannel.dll, digest.dll, msnsspc.dll, credssp.dll (추가)"

windows-server-2012rc-remote-desktop.png



WindowsUpdateFailure 0x800B0001 - Windows Error Reporting

응용프로그램 이벤트 로그

로그 이름: Application 원본: Windows Error Reporting 이벤트 ID: 1001 설명: 오류 버킷 , 유형 0 이벤트 이름: WindowsUpdateFailure 응답: 사용할 수 없음 Cab ID: 0 문제 서명: P1: 7.6.7600.256 P2: 800b0001 P3: D67661EB-2423-451D-BF5D-13199E37DF28 P4: Scan P5: 101 P6: Managed

WindowsUpdate.log 로그

Setup Checking for agent SelfUpdate Setup Client version: Core: 7.6.7600.256 Aux: 7.6.7600.256 Misc Validating signature for C:\Windows\SoftwareDistribution\SelfUpdate\wuident.cab: Misc Microsoft signed: Yes Misc WARNING: Digital Signatures on file C:\Windows\SoftwareDistribution\SelfUpdate\wuident.cab are not trusted: Error 0x800b0001 Setup WARNING: SelfUpdate check failed to download package information, error = 0x800B0001 Setup FATAL: SelfUpdate check failed, err = 0x800B0001 Agent * WARNING: Skipping scan, self-update check returned 0x800B0001 Agent * WARNING: Exit code = 0x800B0001

위와 같은 오류가 발생하는 원인은 업데이트 파일의 서명 검증 오류.

 0x800B0001  => TRUST_E_PROVIDER_UNKNOWN 원인은,  보안 문제로 인증서 체인 서명자를 Microosft 에서 업데이트 했고, 기존 서명자를 파기 했기 때문.

  http://technet.microsoft.com/en-us/security/advisory/2718704

 기존 : Microsoft Code Signing PCA 변경:  Microsoft Update Signing CA 1.1 오류는 Windows Update Service 를 통해서 패치 관리가 되는 클라이언트로,  WSUS 를 최신(Fix) 버젼으로 업데이트를 진행하면 됨.

다운로드 http://support.microsoft.com/kb/2720211


2012/07/18

c#, DateTime to UnixTime / UnixTime to DateTime Convert

public DateTime UnixTimeToDateTime(double value) {
    DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime();
    return unixEpoch.AddSeconds(value);
}
public double DateTimeToUnixTime(DateTime value) {
    TimeSpan span = (value - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime());
    return (double) span.TotalSeconds;
}


MySQL(Connector/Net) 을 이용한 Parameter Query 예

using MySql.Data;
using MySql.Data.MySqlClient;
using(MySqlConnection Con 
= new MySqlConnection("server=yeonpil.org;database=x;user id=x;password=x"))
 {
        MySqlCommand Cmd = new MySqlCommand();
        Cmd.Connection = Con;
        if (Con.State == ConnectionState.Closed) {
            Con.Open();
        }
        Cmd.CommandText = "INSERT INTO Table1 (name) values (?name)";
        Cmd.Parameters.Add("?name", MySqlDbType.VarChar, 50).Value = nameValue; 
// m.Parameters.AddWithValue("@param_val_1", val1);       
// m.Parameters.Add(new MySqlParameter("param1", val1)); 
        Cmd.ExecuteNonQuery(); 
     Cmd.Dispose();
  }

2012/07/17

SyndicationFeed 클래스를 이용한 RSS Feed 읽기

RSS 파서가 많이 있기는 하지만, 프레임워크 내장 클래스 사용 using

System.ServiceModel.Syndication;


var reader = XmlReader.Create(_feedURL);
var feed = System.ServiceModel.Syndication.SyndicationFeed.Load(reader);
if (null == feed) return;
foreach(SyndicationItem item in feed.Items)
 {
    Console.WriteLine(item.Links.FirstOrDefault().Uri.ToString());
    Console.WriteLine(item.Title.Text);
    Console.WriteLine(item.PublishDate.ToString());
}


클래스 상세는 http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.aspx


2012/07/11

c#, html 에서 img src 경로 가져오기


public void getImgs(string _html) {
    Regex rxImages = new Regex("<img.+?src=[\"'](.+?)[\"'].+?>", 
                               RegexOptions.IgnoreCase & RegexOptions.IgnorePatternWhitespace);
    MatchCollection mc = rxImages.Matches(_html);
    foreach(Match m in mc) {
        Console.WriteLine(m.Groups[0].Value);
        Console.WriteLine(m.Groups[1].Value);
    }
}
result: 
0: < img src = "http://yeonpil.org/소녀시대.jpg" / > 
  1: http: //yeonpil.org/소녀시대.jpg


c#, xmlrpc 워드프레스 글 쓰기 예제 (wp.newPost)

using CookComputing.XmlRpc;
public class XmlRpc
{
    public struct blogInfo
    {
        public string post_title;
        public string post_content;
        public DateTime post_date;
        public string post_status;
        public string comment_status;
    }

    // http://codex.wordpress.org/XML-RPC_WordPress_API/Posts
    [XmlRpcUrl(http://yeonpil.org/xmlrpc.php)]
    public interface IWP
    {
        [XmlRpcMethod("wp.newPost")]
        string NewPage(int blogId, string strUserName, 
                                 string strPassword, blogInfo content);
    }
}
public class Wordpress : XmlRpc
{
    public void WritePost(string _title, string _content, 
                                         DateTime _date, string _status)
    {
        blogInfo _post = default(blogInfo);
        _post.post_title = _title;
        _post.post_content = _content;
        _post.post_date= _date;
        _post.post_status = _status;
        _post.comment_status = "open";

        IWP proxy = (IWP)XmlRpcProxyGen.Create(typeof(IWP));
        string result = proxy.NewPage(blogid, "id", "pwd", _post);

        Console.WriteLine("postID: " + result);
    }
}
 



워드프레스 API, wp.newPost(글쓰기)

Parameters
  • int blog_id
  • string username
  • string password
  • struct content
    • string post_type
    • string post_status
    • string post_title
    • int post_author
    • string post_excerpt
    • string post_content
    • datetime post_date_gmt | post_date
    • string post_format
    • string post_password
    • string comment_status
    • string ping_status
    • bool sticky
    • int post_thumbnail
    • int post_parent
    • array custom_fields
      • struct
        • string key
        • string value
    • struct terms: Taxonomy names as keys, array of term IDs as values.
    • struct terms_names: Taxonomy names as keys, array of term names as values.
    • struct enclosure
      • string url
      • int length
      • string type
    • any other fields supported by wp_insert_post

Return Values

  • string post_id

Errors

  • 401
    • If the user does not have the edit_posts cap for this post type.
    • If user does not have permission to create post of the specified post_status.
    • If post_author is different than the user's ID and the user does not have the edit_others_posts cap for this post type.
    • If sticky=true and user does not have permission to make the post sticky.
    • If a taxonomy in terms or terms_names is not supported by this post type.
    • If terms or terms_names is set but user does not have assign_terms cap.
    • If an ambiguous term name is used in terms_names.
  • 403
    • If invalid post_type is specified.
    • If an invalid term ID is specified in terms.
  • 404
    • If no author with that post_author ID exists.
    • If no attachment with that post_thumbnail ID exists.
http://codex.wordpress.org/XML-RPC_WordPress_API/Posts http://codex.wordpress.org/Function_Reference/wp_insert_post  

가장 많이 본 글