AD attribute Modify - Please help RRS feed

  • Question

  • I am getting "Server is Unwilling to process the request."
    I need to update the Email ID field for users in AD using, I am able to search the users in AD all okay, not able to update any field, however.

    Even tried to update other fields "homePhone", that too fails with same error, please help.

    '' Hers my code..

      Dim ADEntry As New DirectoryServices.DirectoryEntry("<Domain Name>")
        Dim ADSearch As New System.DirectoryServices.DirectorySearcher(ADEntry)
               Dim Result As String
              ADSearch.Filter = ("(samAccountName=" & UserName & ")")
              ADSearch.SearchScope = SearchScope.Subtree
        Dim MachineFoundAD As SearchResult = ADSearch.FindOne()
        If Not IsNothing(MachineFoundAD) Then
            Dim mailID As String
            Dim attrUpdate As New System.DirectoryServices.DirectoryEntry(MachineFoundAD.Path)
            Result = MachineFoundAD.GetDirectoryEntry().Properties.Item("cn").Value
             MsgBox("FOUND USER  " & Result) ' Getting Search Results fine 
           attrUpdate.Properties("mail").Value = ""
        End If
    End Sub

    Saturday, July 9, 2016 2:05 PM


  • I am not sure but some times back  I faced a similar issue while creating user account in AD and then modifying the attribute values . I first set the password for the user then commit the changes , after that I modified the attributes  and  then again called CommitChanges() to save the changes .

    But this is provided that the user running the application must have access to modify the contents , otherwise you have to provide credentials before making the change.

    Saturday, July 9, 2016 3:13 PM