2011-01-20 6 views
1

현재 사용자는 AD에 대해 유효성이 검사 된 AD (Active Directory) 자격 증명을 사용하여 웹 응용 프로그램에 로그인합니다. 일단 응용 프로그램 내부에, 특정 사용자는 광고를 업데이 트해야합니다. 사용자 이름/암호를 하드 코드 할 때 AD를 업데이트 할 수 있지만 로그온 자격 증명을 사용하도록 개체를 강제로 시도하거나 사용자 이름/암호를 지정하지 않으면 오류가 발생합니다. 보안 문제 때문에 분명히 자격 증명을 하드 코딩하고 싶지 않습니다. 이것에 대한 해결책이 있습니까?사용자 이름/암호 하드 코드없이 Active Directory 업데이트

오류 - System.DirectoryServices.DirectoryServicesCOMException : 작업 오류가 발생했습니다. 사용자 IIS가 (기본적으로 가장 확실하지 않음), 또는 설정해야 AD 편집 권한이 필요에 따라 실행 중

Public Shared Sub SetProperty(ByVal de As DirectoryEntry, ByVal propName As String, ByVal propValue As String) 
     If Not propValue Is Nothing Then 
      If de.Properties.Contains(propName) Then 
       de.Properties(propName)(0) = propValue 
      Else 
       de.Properties(propName).Add(propValue) 
      End If 
     End If 
    End Sub 

    Public Shared Function GetDirectoryEntry(ByVal path As String) As DirectoryEntry 
     Dim de As New DirectoryEntry() 
     de.Path = path 
     de.Username = "<username>" 
     de.Password = "<password>" 
     'Not setting the username or password or setting both to Nothing throws the error 
     de.AuthenticationType = AuthenticationTypes.Secure 
     Return de 
    End Function 

    Dim de As DirectoryEntry = GetDirectoryEntry("<path>") 
    Dim searcher As DirectorySearcher = New DirectorySearcher(de) 
    searcher.Filter = "(&(objectCategory=person)(objectClass=user)(cn=" & fullName & "))" 
    searcher.SearchScope = SearchScope.SubTree 
    Dim result As SearchResult = searcher.FindOne() 

    If Not result Is Nothing Then 
     Dim deResult As New DirectoryEntry(result.Path) 
     SetProperty(deResult, "accountExpires", toAccountExpirationDate) 
     deResult.CommitChanges() 
     deResult.Close() 
    End If 

    de.Close() 
+0

winforms 또는 asp.net입니까? –

+0

그것은 asp.net, 내가 태그를 업데이 트거야. –

답변

1

작업을 수행하기 전에 자격 증명을 지정할 필요가 없습니다하기 위해, 가장을 사용하여 페이지를 보는 사용자로 실행되도록 Windows 인증을 사용합니다.

두 번째 사례는 "이중 홉"을 할 수 없기 때문에 어려움이 있습니다. 즉 웹 서버가 도메인 컨트롤러 여야하거나 서버에 여분의 AD delegation 권한을 설정해야합니다. 귀하의 도메인 관리자는 당신을주고 싶어하지 않을 수도 있습니다.

이 경우 문제의 해결책은 응용 프로그램이 실행중인 사용자 계정을 이미 필요한 권한이있는 사용자 계정으로 변경하는 것입니다. 그 위험은 보안 구멍이 공격자에게 동일한 권한을 부여한다는 것입니다.

또는 일부 자격 증명을 암호화하고 해독하여 사용할 수 있습니다. 하드 코딩보다 약간 낫습니다. 나는 사용자가 수동으로 자격 증명을 제공하고 하드 코딩 된 코드를 사용하는 것과 같은 방식으로 사용할 수 있다고 생각합니다.