よろしくお願いします。 ADに参加していないPCとADサーバが同じネットワーク上に有ります。 このPCからADサーバへファイル共有等で接続は可能な状態です。 VBで作成したアプリをこのPCで起動した際に、ADに登録したユーザー名・パスワードを入力し情報(表示名等)を取得し、認証及び誰が使用したのかログを残したいと思います。 VBで以下のコードを試しました。 Dim path As String = "LDAP://ADサーバのIPアドレス" Dim root As New DirectoryEntry(path, "ユーザー名", "パスワード") Dim schr As New DirectorySearcher(root) schr.Filter = String.Format("(&(objectClass=user)(name={0}))", "ユーザー名") Dim sr As SearchResult = schr.FindOne() Dim userEntry = sr.GetDirectoryEntry() Dim fullName As String = userEntry.Properties("fullName").Value userEntry.Close() root.Close() や Dim path As String = "LDAP://ADサーバのIPアドレス" Dim root As New DirectoryEntry(path) root.Username ="ユーザー名" root.Password ="パスワード" Dim schr As New DirectorySearcher(root) schr.Filter = String.Format("(&(objectClass=user)(name={0}))", "ユーザー名") Dim sr As SearchResult = schr.FindOne() Dim userEntry = sr.GetDirectoryEntry() Dim fullName As String = userEntry.Properties("fullName").Value userEntry.Close() root.Close() では、情報を取得できません。 上記以外にもサーバのIPアドレスの後ろに”/DC=ドメイン名,DC=local”等を追加したり、検索して見つけたコードをいろいろ試しましたが失敗の連続です。 どのようにすればADサーバから情報を取得出来るかご存知の方が居られましたら、ご教授をお願いいたします。 お手数をお掛け致しますが、よろしくお願いいたします。
↧