|
-
Aug 31st, 2008, 12:54 PM
#1
Thread Starter
Member
[RESOLVED] [2008] pwdLastSet and AD
Hi All
So i am using the below which work perfectly i now need to get the pwdLastSet for the user.
How would i go about this?
Thanks
Code:
Module ad_lookup
' Public variabled used across the whole application
Public strcn As String
Public strtele As String
Public strtitle As String
Public strdepartment As String
Public strtelephone As String
Public strcompany As String
Public strmail As String
Public strmobile As String
Public strsn As String
Public strgivenname As String
Public strl As String
Public strhome As String
Public strpwddate As Date
' struser gets the username so it can be used in the AD lookup script
Public struser As String = System.Environment.UserName
' Function to connect to AD
Public Function GetDirectoryEntry() As DirectoryServices.DirectoryEntry
Dim de As DirectoryServices.DirectoryEntry = New DirectoryServices.DirectoryEntry()
de.Path = "LDAP://DC=xxx,DC=com"
Return de
End Function
Public Sub get_user_info(ByVal userid As String)
Dim ds As New DirectoryServices.DirectorySearcher(GetDirectoryEntry)
ds.Filter = "((samaccountname=" & struser & "))"
Dim results As System.DirectoryServices.SearchResultCollection = ds.FindAll()
For Each result As System.DirectoryServices.SearchResult In results
strcn = (result.Properties("cn")(0).ToString())
strtitle = (result.Properties("title")(0).ToString)
strdepartment = (result.Properties("department")(0).ToString)
strcompany = (result.Properties("company")(0).ToString)
If Not IsNothing(result.Properties("mail")(0).ToString) Then
strmail = (result.Properties("mail")(0).ToString)
Else
strmail = ""
End If
If Not IsNothing(result.Properties("TelephoneNumber")(0).ToString) Then
strtelephone = (result.Properties("TelephoneNumber")(0).ToString)
Else
strtelephone = ""
End If
If Not IsNothing(result.Properties("mobile")(0).ToString) Then
strmobile = (result.Properties("mobile")(0).ToString)
Else
strmobile = ""
End If
strsn = (result.Properties("sn")(0).ToString)
strgivenname = (result.Properties("GivenName")(0).ToString)
strl = (result.Properties("l")(0).ToString)
If Not IsNothing(result.Properties("HomeDirectory")(0).ToString) Then
strhome = ""
Else
strhome = (result.Properties("HomeDirectory")(0).ToString)
End If
Next
End Sub
End Module
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|