FLPeople
asked on
Get Active Directory Domain Password Policy Attribute
I've seen lots of C# code to get this, but how do I get the default domain password policy - specifically the maxPwdAge attribute using VB.NET?
Here's my first line of code:
Here's my first line of code:
Dim objRootDSE As New DirectoryEntry("LDAP://RootDSE")
oops, just realized it refers to user and not computer. Try this:
Dim DirEntry As DirectoryEntry = New DirectoryEntry(AdsiPath, "username", "password")
Dim oSearcher As DirectorySearcher = New DirectorySearcher(DirEntry )
Dim resultset As SearchResult
With oSearcher
.Filter = ("(objectClass=user)")
.PageSize = 5000
End With
resultset = oSearcher.FindAll();
if resultset.Properties.Conta ins("maxPw dAge") then
maxPwdAge = resultset.Properties("maxP wdAge")
end if
Dim DirEntry As DirectoryEntry = New DirectoryEntry(AdsiPath, "username", "password")
Dim oSearcher As DirectorySearcher = New DirectorySearcher(DirEntry
Dim resultset As SearchResult
With oSearcher
.Filter = ("(objectClass=user)")
.PageSize = 5000
End With
resultset = oSearcher.FindAll();
if resultset.Properties.Conta
maxPwdAge = resultset.Properties("maxP
end if
could you tell me exactly what are you trying to do
ASKER
I am trying to find out how many days it will be until users' passwords expire in VB.NET.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Came up with my own math to convert C# code to VB.NET
Dim DirEntry As DirectoryEntry = New DirectoryEntry(AdsiPath, "username", "password")
Dim oSearcher As DirectorySearcher = New DirectorySearcher(DirEntry
Dim resultset As SearchResult
With oSearcher
.Filter = ("(objectClass=computer)")
.PageSize = 5000
End With
resultset = oSearcher.FindAll();
if resultset.Properties.Conta
maxPwdAge = resultset.Properties("maxP
end if