Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Active directory Question

Active directory Question

Scheduled Pinned Locked Moved C#
questiondatabasewindows-admin
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    caiena
    wrote on last edited by
    #1

    i have a program that authenticated users with Active directory how do i query AD to find out when is the last time a user was authenicated i trided using last logon time but this is only updated when they log on to the computer not when the authenticate

    L S 2 Replies Last reply
    0
    • C caiena

      i have a program that authenticated users with Active directory how do i query AD to find out when is the last time a user was authenicated i trided using last logon time but this is only updated when they log on to the computer not when the authenticate

      L Offline
      L Offline
      Leonscape
      wrote on last edited by
      #2

      lastlogon is notorious in fact it doesn't even replicate if you have more than one DC. Try lastlogontimestamp. However this only works with 2003 server and above, and they have to be in the correct 2003 Domain mode. No 2000 servers. Otherwise it's lastlogon and checking all the servers. and even then it might not be accurate.

      Using the wrong tool for the job is half the fun.

      1 Reply Last reply
      0
      • C caiena

        i have a program that authenticated users with Active directory how do i query AD to find out when is the last time a user was authenicated i trided using last logon time but this is only updated when they log on to the computer not when the authenticate

        S Offline
        S Offline
        saurabh sahay
        wrote on last edited by
        #3

        Login Using Active Directory Services (ADS) In order to use SDS, first we have to set properties of LDAP server. Here database ADSI_PARAMETER table is used to set the LDAP properties. CREATE TABLE [dbo].[ADSI_PARAMETER] ( [ParameterName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [ParameterValue] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ) ON [PRIMARY] GO Enter following data to table in ParameterName and ParameterValue fields Parameter Name ParameterValue ServerName WindowsDomainServer BaseDN DC=DomainName,DC=COM UserDN OU=Users GroupName CN=Operater, OU=Groups AccountFilter sAMAccountName Where ServerName is your domain server machine name. BaseDN is your domain name, most of the time it is company name. UserDN is organizational unit where user should exist. GroupName is organizational unit, to which user should belong in order to access your software. AccountFilter is filter for account name; mostly it is sAMAccountName in windows. Code for GetADSILogin function. public void GetADSILogin() { try { string strServerName = ""; string strBaseDN = "" ; string strUserDN = ""; string strGroupName = ""; string strAccountFilter = ""; //Port no for LDAP Default is 389 string strPortNo = "389"; Boolean blnGroupUser=false; //Data source string string source = "Data Source=ATHAKUR;Initial Catalog=Times;user=sa;password=sa" ; //SQL statement that will be issued string select = "SELECT * from ADSI_PARAMETER"; //SQL Connection SqlConnection conn=new SqlConnection(source); // Open the database connection conn.Open () ; // Create the SQL command... SqlCommand cmd = new SqlCommand ( select , conn ) ; //Execute Data reader SqlDataReader myReader = cmd.ExecuteReader(); //Check if any rows return against user/pass if(myReader.HasRows) { while(myReader.Read()) { //Store the parameter's data in variables string strParameterName = myReader.GetSt

        D 1 Reply Last reply
        0
        • S saurabh sahay

          Login Using Active Directory Services (ADS) In order to use SDS, first we have to set properties of LDAP server. Here database ADSI_PARAMETER table is used to set the LDAP properties. CREATE TABLE [dbo].[ADSI_PARAMETER] ( [ParameterName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [ParameterValue] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ) ON [PRIMARY] GO Enter following data to table in ParameterName and ParameterValue fields Parameter Name ParameterValue ServerName WindowsDomainServer BaseDN DC=DomainName,DC=COM UserDN OU=Users GroupName CN=Operater, OU=Groups AccountFilter sAMAccountName Where ServerName is your domain server machine name. BaseDN is your domain name, most of the time it is company name. UserDN is organizational unit where user should exist. GroupName is organizational unit, to which user should belong in order to access your software. AccountFilter is filter for account name; mostly it is sAMAccountName in windows. Code for GetADSILogin function. public void GetADSILogin() { try { string strServerName = ""; string strBaseDN = "" ; string strUserDN = ""; string strGroupName = ""; string strAccountFilter = ""; //Port no for LDAP Default is 389 string strPortNo = "389"; Boolean blnGroupUser=false; //Data source string string source = "Data Source=ATHAKUR;Initial Catalog=Times;user=sa;password=sa" ; //SQL statement that will be issued string select = "SELECT * from ADSI_PARAMETER"; //SQL Connection SqlConnection conn=new SqlConnection(source); // Open the database connection conn.Open () ; // Create the SQL command... SqlCommand cmd = new SqlCommand ( select , conn ) ; //Execute Data reader SqlDataReader myReader = cmd.ExecuteReader(); //Check if any rows return against user/pass if(myReader.HasRows) { while(myReader.Read()) { //Store the parameter's data in variables string strParameterName = myReader.GetSt

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          That's alot of work and a complete waste considering you didn't even the the OP's question...

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups