Aug 11, 2014 12:24 PM|searcherrr|LINK
I'm very rusty on web development, but I used to do it all the time prior to 2010.
I have what should be a very simple task. I basically just want to start learning ASP.NET (I used to do ASP classic very well) by performing this simple task:
1. Create an ASP.NET web page using VB that searches our DC for "Name" and "Phone" number.
I'm an IT Admin at a clinic (handling many tasks) and all I want to do is populate AD with the clinic phone numbers and provide a simple 1 web page search of this information.
Here is the code I have so far, but I feel I'm way off base. Can someone help me get this right so I can get my dev feet wet again?
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %>
<%@ import Namespace="System.DirectoryServices" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<form id="form1" runat="server">
Dim Domain1 As System.DirectoryServices.DirectoryEntry = New System.DirectoryServices.DirectoryEntry("LDAP://domainName.local/OU=DOMAINUSERS,DC=domainName,DC=local", "Administrator", "Password!", AuthenticationTypes.ReadonlyServer)
Dim Searcher1 As System.DirectoryServices.DirectorySearcher = New System.DirectoryServices.DirectorySearcher("(&(objectCategory=Person)(objectClass=user)")
Dim Lista1 As New System.Collections.Generic.List(Of String)()
Searcher1.SearchRoot = Domain1
Searcher1.SearchScope = SearchScope.Subtree
Dim Results1 As SearchResultCollection
Results1 = Searcher1.FindAll()
Dim Results As Integer
Results = Results1.Count
If Results <> 0 Then
For i As Integer = 0 To Results1.Count
Throw New ArgumentException("its aruging")
Currently this code is bombing out at Results.Count with an ArgumentException and I have tried to look this up, and cannot understand the meaning of it.
I also realize I'm not calling a "name" or "phone" property or field value per say yet, but I was just trying to make a successful connection to our AD server to see if I can even do this....... get a simple NAME and associated PHONE number.
HELP!!! Please don't flame me!! I'm trying! :)