HEJ! Jag löste det med:DirectorySearcher - > logonCount
Jag försöker att få fram lite info ur vårt AD.
Men jag fattar inte hur hur jag skall få fram värderna på egenskaperna?
Sätter man en breakpoint och tittar i 'Autos' så kan jag ju se värderna om man klickar sig ner.
Någon som hinner förklara hur man skall tänka?
/Alexander
<code>
private void Form1_Load(object sender, System.EventArgs e)
{
DirectorySearcher srch = new DirectorySearcher();
SearchResultCollection results;
srch.Filter = "(objectClass=User)";
results = srch.FindAll();
foreach (SearchResult sr in results)
{
KollaVarjeUser(sr.GetDirectoryEntry());
//this.AntalUser += 1;
}
//Console.WriteLine("Antal user: " + this.AntalUser);
//Console.WriteLine("Antal egenskaper: " + this.AntalEgenskaper);
}
public void KollaVarjeUser(DirectoryEntry de)
{
System.Collections.IEnumerator I;
//I =de.Properties.PropertyNames.GetEnumerator(); // Denna listar alla namn...men inga värden...
I =de.Properties.GetEnumerator(); // Denna listar alla egenskaper.
while(I.MoveNext())
{
Console.WriteLine(I.Current);
//this.AntalEgenskaper += 1;
}
/*
objectClass
cn
sn
givenName
distinguishedName
instanceType
whenCreated
whenChanged
displayName
uSNCreated
memberOf
uSNChanged
name
objectGUID
userAccountControl
badPwdCount
codePage
countryCode
homeDirectory
homeDrive
badPasswordTime
lastLogoff
lastLogon
pwdLastSet
primaryGroupID
profilePath
objectSid
accountExpires
logonCount
sAMAccountName
sAMAccountType
userPrincipalName
lockoutTime
objectCategory
lastLogonTimestamp
nTSecurityDescriptor
objectClass
cn
sn
givenName
distinguishedName
instanceType
whenCreated
whenChanged
displayName
uSNCreated
memberOf
uSNChanged
name
objectGUID
userAccountControl
badPwdCount
codePage
countryCode
homeDirectory
homeDrive
badPasswordTime
lastLogoff
lastLogon
pwdLastSet
primaryGroupID
profilePath
objectSid
accountExpires
logonCount
sAMAccountName
sAMAccountType
userPrincipalName
lockoutTime
objectCategory
lastLogonTimestamp
nTSecurityDescriptor
*/
}
</code>Sv: DirectorySearcher - > logonCount
<code>
res.Properties["logonCount"][0].ToString());
</code>