Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

Fetch latslogon details from Active directory using C#.NET

$
0
0

We are using a website which will evaluate the user credentials from Activedirectory in a specific group.

Now we want to create a report from AD, it should contains the list of users from that specific group and when they access the website last time.

Below piece of code will correctly list the users available on the specific group.

I wrote another piece code to return the lastlogon datetime for each users  in that group. But that will list the date time under 'HUMAD' domain not from that particular group.

DirectoryEntrydeUsers =            

newDirectoryEntry("LDAP ://  XXXXX");

DirectorySearcherdsUsers =newDirectorySearcher(deUsers);

dsUsers.PropertiesToLoad.Add(

"cn");

dsUsers.PropertiesToL

}oad.Add(

"SAMAccountname");

            dsUsers.Filter =

"(&(ObjectClass=user)(memberof=g_cms_readonly))";

vardomainContext =newPrincipalContext(ContextType.Domain);

vargroupPrincipal =GroupPrincipal.FindByIdentity(domainContext,IdentityType.SamAccountName,g_cms_readonly);

foreach(PrincipalmingroupPrincipal.Members)

                    {

                        }

Environment.NewLine+ m.SamAccountName + "  "+ m.Name + "  "+dt+" ";

I use ADExplorer tool and didn't see any attributes available for that specific group to check last logon time. Using .NET, is there any way to find that?

Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>