현재 사용자는 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()
winforms 또는 asp.net입니까? –
그것은 asp.net, 내가 태그를 업데이 트거야. –