2016-05-17 8 views
0

この機能を使用してユーザー名(すべてのユーザーは同じドメインにあります)からユーザーの電子メールアドレスを検索できましたが、 Windowsの10にアップグレードされて、私はエラーを取得しています:LDAPサーバーがWindows 10で正常に動作しない

The server is not operational

私はこの質問を参照して答えを自分のコードに変更を加えた、今私は、デフォルトのネーミングコンテキストを拾うが、エラーが解消されません: System.DirectoryServices - The server is not operational

Public Function UserEmail(ByRef Username As String) As String 
     UserEmail = "" 
     Dim deRoot As New DirectoryServices.DirectoryEntry("LDAP://RootDSE") 

     If Not deRoot Is DBNull.Value Then 
      Dim defaultNamingContext As String = deRoot.Properties("defaultNamingContext").Value.ToString() 
      Dim path As String 
      path = "LDAP://" & defaultNamingContext 


      Dim entry As New DirectoryServices.DirectoryEntry(Path) 
      Dim search As New DirectoryServices.DirectorySearcher(entry) 

      search.Filter = "(&(objectClass=user)(anr=" + Username + "))" 
      search.PropertiesToLoad.Add("mail") 

      Dim result As DirectoryServices.SearchResult 
      result = search.FindOne 

      If IsDBNull(result) Then 
       UserEmail = "" 
      Else 
       UserEmail = result.Properties("mail")(0) 
      End If 

     End If 

    Return UserEmail 
End Function 

コードは、ユーザーがWindows 7と8を使用しているところで正常に動作します。

ご意見はありますか?

+0

このコードは各ユーザーのマシンで実行されますか? –

+0

はい、Windows 7と8では問題なく動作しますが、Windows 10ではエラーが発生します。そのユーザー名がデータベースに保存されている別のユーザーに電子メールを送信します。 – DovesandChicks

+0

これらのWindows 10マシンは、Windows 7/8と同じドメインに参加していますか? –

答えて

0

なぜLDAP:// RootDSEでクラッシュするのか分かりません。しかし、ドメインが1つだけの場合は、RootDSEを使用するのではなく、ドメイン名をハードコードすることができます。

あなたは、ドメインのDNS名のいずれかを使用することができます。

Dim entry As New DirectoryServices.DirectoryEntry("LDAP://domain.com") 

またはドメインの識別名:それは何の違いを行う場合

Dim entry As New DirectoryServices.DirectoryEntry("LDAP://DC=domain,DC=com") 

を参照してください。

関連する問題