I am really new to LDAP programming with ASP.net 2.0 and I had a few questions...
First off, when searching for objects in AD when should you use the RootDSE object instead of the regular LDAP:\\OU=OUName,DC=DCName,DC=Com?
Second, I snagged a code snippit to help me learn and (code posted below) had a few questions about the code, first can you tell which computers are orphaned or disabled using this method, also can you see which stations haven't changed their passwords in
say over 60 days? Same questions about user accounts (I havent ventured into user accounts just yet). I am learning as I go and would really appreciate any help you guys can provide :)
[code]
Imports
System.DirectoryServices
Partial
Class Test
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender
As Object,
ByVal e As System.EventArgs)
Handles Me.Load
Dim adsRoot
As New DirectoryEntry(LDAP://OU=OUName,DC=DCName,DC=Com)
Dim adsUser, adsComputer
As DirectoryEntry
Dim strCompName
As String
Dim ocnt As
Integer
For Each adsComputer
In adsRoot.Children
If adsComputer.SchemaClassName =
"computer" Then
None
0 Points
15 Posts
Questions about a few things LDAP
Jun 04, 2006 02:25 PM|supermanzdead|LINK
I am really new to LDAP programming with ASP.net 2.0 and I had a few questions...
First off, when searching for objects in AD when should you use the RootDSE object instead of the regular LDAP:\\OU=OUName,DC=DCName,DC=Com?
Second, I snagged a code snippit to help me learn and (code posted below) had a few questions about the code, first can you tell which computers are orphaned or disabled using this method, also can you see which stations haven't changed their passwords in say over 60 days? Same questions about user accounts (I havent ventured into user accounts just yet). I am learning as I go and would really appreciate any help you guys can provide :)
[code]
Imports
System.DirectoryServicesPartial
Class Test Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim adsRoot As New DirectoryEntry(LDAP://OU=OUName,DC=DCName,DC=Com) Dim adsUser, adsComputer As DirectoryEntry Dim strCompName As String Dim ocnt As Integer For Each adsComputer In adsRoot.Children If adsComputer.SchemaClassName = "computer" ThenstrCompName = Mid(adsComputer.Name, 4)
Response.Write(strCompName &
":")Response.Write(adsComputer.Properties(
"whenCreated").Value & ":")Response.Write(adsComputer.Properties(
"operatingsystem").Value & " ")Response.Write(adsComputer.Properties(
"operatingsystemservicePack").Value & " ") 'Response.Write(adsComputer.Properties("lastLogon").Value)ocnt = ocnt + 1
Try 'adsUser = New DirectoryEntry("WinNT://" & Trim(strCompName) & "/Administrator") 'Response.Write(adsUser.Properties("MaxPasswordAge").Value / 86400 & ", ") 'Response.Write(adsUser.Properties("MinPasswordLength").Value & ", ") 'Response.Write(adsUser.Properties("PasswordHistoryLength").Value & ", ") 'Response.Write(adsUser.Properties("MaxBadPasswordsAllowed").Value & ", ") 'Response.Write(adsUser.Properties("AutoUnlockInterval").Value & ", ") 'Response.Write(adsUser.Properties("LockOutObservationInterval").Value & ", ") Catch ex As ExceptionResponse.Write(ex.Message &
"<br>") End TryResponse.Write(
"<br>") End If NextResponse.Write(ocnt &
" Workstations Flagged.")[/code]