Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

windows Active Directory

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I want to connect to my servers Active Directory folder and store it in a dataset. Can anyone help me with this? I have never done this before.

Scott
 
I haven't found much but the right direction is to look for LDAP instructions. Check this out:

thread855-400189

hth

Daren J. Lahey
Just another computer guy...
FAQ183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
Support your forums TODAY!
 
well and here is how I am trying to do it, but nothing is displaying on the screen

Try
txtUserID.Text = "sthompson"
txtPassword.Text =
'Authenticates user name and password with the AD
Dim Entry As New DirectoryEntry("LDAP://AM1ST.COM", txtUserID.Text, txtPassword.Text)
Dim Search As New DirectorySearcher(Entry)
Search.PropertiesToLoad.Add("Name")
Dim searchstrg As String
searchstrg = "(&(CN=Thompson)(objectCategory=users))"
Search.Filter = searchstrg
Dim results As SearchResultCollection
results = Search.FindAll()
Response.Write("Good Authentication")

Dim result As SearchResult
For Each result In results
Response.Write(result.Properties("Name")(0))
Response.Write("hello")
Next
'clears text box and resets focus
txtUserID.Text = ""
txtPassword.Text = ""

Catch Err As Exception
Response.Write(Err.Message)
txtUserID.Text = "Missed"
txtPassword.Text = ""
End Try
 
take the objectcategory off from:

searchstrg = "(&(CN=Thompson)(objectCategory=users))"


hth Daren J. Lahey
Just another computer guy...
FAQ183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
Support your forums TODAY!
 
I put it like this searchstrg = "(&(anr=sthompson))"
and now I get this error displayed

Object reference not set to an instance of an object.
 
putting it like this

searchstrg = "(&(cn=sthompson)(users))"

gives me

The (&(cn=sthompson)(users)) search filter is invalid.
 
this is how it works for me:

searchstrg = "(&(CN=Daren J. Lahey))"

you need to use your full name if possible. It's not that nice but it's the only workaround (sofar) that I have found.
Daren J. Lahey
Just another computer guy...
FAQ183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
Support your forums TODAY!
 
Okay that works, but then why doesn't this part run. I never see Response.Write("hello") show up.

Dim result As SearchResult
For Each result In results
Response.Write(result.Properties("displayName")(0))
Response.Write("hello")
Next

and say display that property of the thing, or as I had above Name. ????
 
use this loop:
Code:
mySearcher.Filter = "(CN=" + strFullName + ")";
SearchResult sr = mySearcher.FindOne();
string strUserGroup;
ResultPropertyCollection myResultPropColl = sr.Properties;
foreach(string sc in myResultPropColl.PropertyNames) 
{
  if(sc == "memberof") 
  {
    for (int w = 0; w < myResultPropColl[sc].Count; w++) 
    {
      strUserGroup = (myResultPropColl[sc])[w].ToString();
      strUserGroup = strUserGroup.Remove(0,3);
      strUserGroup = strUserGroup.Remove(strUserGroup.IndexOf(&quot;,&quot;,0,strUserGroup.Length-1),(strUserGroup.Length - strUserGroup.IndexOf(&quot;,&quot;,0,strUserGroup.Length-1)));
    }
  }
}

and instead of &quot;memberof&quot; put displayName Daren J. Lahey
Just another computer guy...
FAQ183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions.
Support your forums TODAY!
 
If I change the search string to searchstrg = &quot;(&(cn=*))&quot; it displays everything in my domain. All the computers, Names, Printers, everything. I want to grab all the users and display all of them, not just one.
 
I'll look into this later today. I see what you need to do.
Like you I tried to use the &quot;objectCategory=users&quot; filter but I never got results.
I'll hit the books and get back to you soon.
Daren J. Lahey
Just another computer guy...
FAQ183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions.
Support your forums TODAY!
 
This line changed grabbed just the users

LDAP://CN=Users,DC=am1st,DC=com&quot;

 
where am1st is the domain name, right? Daren J. Lahey
Just another computer guy...
FAQ183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions.
Support your forums TODAY!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top