Hello,
i try to read user information from the ActiveDirectory with OleDB. Most work already. But currently i have problems to get the Data when the User Password will expire.
The Data is saved in an integer8 field but i don't get the expected value in my code.
identification division. program-id. test-ad. ************************************************************* * * * * * * ************************************************************* author. David Neidinger. date-written. environment division. configuration section. special-names. decimal-point is comma copy "adodb.def". . input-output section. *********************************************************** file-control. data division. file section. *********************************************************** working-storage section. *** Ado Handling 77 adoConnection handle of @Connection of @ADODB. 77 adoRecordset handle of @Recordset of @ADODB. 77 adoFields handle of @Fields of @ADODB. 77 adoCommand handle of @Command of @ADODB. 77 adoConnStr pic x(256). 77 adoSyntax pic x(5048). 77 adoConnState pic s9(9). 77 hlp-test1 pic x(255). 77 hlp-test2 pic x(255). 77 hlp-test3 pic x(10). 77 hlp-test4 pic s9(18) comp-5. 77 i-userAccountControl pic 9(10). 77 c-userAccountControl pic x(32). 01 uf-userAccountControl. 03 uf-account-disable pic x(5) value "false". 03 uf-homedir-required pic x(5) value "false". 03 uf-lockout pic x(5) value "false". 03 uf-pwd-notreqd pic x(5) value "false". 03 uf-pwd-cant-change pic x(5) value "false". 03 uf-pwd-text-allowed pic x(5) value "false". 03 uf-normal-account pic x(5) value "false". 03 uf-intdom-trust-account pic x(5) value "false". 03 uf-wks-trust-account pic x(5) value "false". 03 uf-srv-trust-account pic x(5) value "false". 03 uf-dont-expire-pwd pic x(5) value "false". 03 uf-mns-logon-account pic x(5) value "false". 03 uf-smartcard-required pic x(5) value "false". 03 uf-trusted-for-deleg pic x(5) value "false". 03 uf-not-delegated pic x(5) value "false". 03 uf-use-des-key-only pic x(5) value "false". 03 uf-dont-require-preauth pic x(5) value "false". 03 uf-password-exired pic x(5) value "false". 03 uf-trusted-to-auth-del pic x(5) value "false". 03 uf-no-auth-data-required pic x(5) value "false". 03 uf-partial-secrets-acc pic x(5) value "false". 77 counter pic 9(5) value zeroes. 77 idx pic 9(2) value zeroes. 77 hlp-digit pic 9 value zeroes. 01 Windows-Dateizeitstempel PIC S9(18) COMP-5. 01 Windows-Datei-Epoche PIC S9(18) COMP-5 VALUE 116444736000000000. 01 NumericalValue PIC 9(18) COMP-5. 01 Jahr PIC 9(4). 01 Tag PIC 9(3). 01 Stunde PIC 9(2). 01 Minute PIC 9(2). 01 Sekunde PIC 9(2). 01 COBOL-Datum-Uhrzeit-Str PIC X(20). 77 oEnabled pic x(5) value spaces. copy "resultat.cpy". *********************************************************** procedure division. declaratives. copy "dec-all.cpy". end declaratives. *********************************************************** main section. *** Connection String definieren string "Provider=ADsDSOObject" delimited by size into adoConnStr. *** Instanz für AdoDB erzeugen create @Connection of @ADODB handle in adoConnection. *** Verbindung aufbauen modify adoConnection @Open(adoConnStr). *** Verbindungs-Status abfragen main-connect. inquire adoConnection @State in adoConnState. evaluate adoConnState when adStateOpen continue when adStateClosed destroy adoConnection go to main-disconnected when adStateConnecting go to main-connect when adStateExecuting destroy adoConnection go to main-disconnected when adStateFetching destroy adoConnection go to main-disconnected end-evaluate. *** Create Command create @Command of @ADODB handle in adoCommand. modify adoCommand @ActiveConnection = adoConnection. modify adoCommand @Properties::@item("Page Size")::@value = 500. modify adoCommand @Properties::@item("Cache Results")::@value = 1. *** Create Recordset create @Recordset of @ADODB handle in adoRecordset. *** Read AD initialize adoSyntax. string "<LDAP://B00DCFRIBM12/" "OU=B00-SGTS-USS,DC=zb,DC=if,DC=atcsg,DC=net>" ";(&(objectCategory=person)(objectClass=user))" ";samAccountName" | SGI ",givenName" | Vorname ",sn" | Nachname ",displayName" | DisplayName ",description" | Beschreibung ",mail" | Mail ",extensionAttribute8" | Attribute8 ",distinguishedName" | OU ",manager" | ManagerOU ",whenCreated" | WhenCreated ",whenChanged" | WhenChanged ",lastLogon" | LastLogon ",lastLogonTimestamp" | LastLogonTimestamp ",userWorkstations" | Anmeldearbeitsstationen ",userAccountControl" | zum Enabled/Disabled ",pwdLastSet" | Passwort zuletzt gesetzt ",msDS-UserPasswordExpiryTimeComputed" | PassWordExpire (Integer) ",physicalDeliveryOfficeName" | Büro ",title" | Dienststellung ",department" | Abteilung ",company" | Firma ",c" | Ländercode ",co" | Land ",l" | Stadt ",postalCode" | Postleitzahl ",streetAddress" | Straße ",personalTitle" | Anrede ",division" | Division ",telephoneNumber" | Telefonnummer ",mobile" | Mobiltelefonnummer ";subtree" delimited by size into adoSyntax. modify adoCommand @CommandText = adoSyntax. modify adoCommand @Execute() returning adoRecordset. *** go to first record modify adoRecordset @MoveFirst(). inquire adoRecordset @EOF in adoConnState. *** loop data perform until adoConnState = -1 inquire adoRecordset @fields::@item("samAccountName")::@value in hlp-test1 @fields::@item("pwdLastSet ")::@value in hlp-test2 @fields::@item("userAccountControl")::@value in hlp-test3 @fields::@item ("msDS-UserPasswordExpiryTimeComputed")::value in hlp-test4 display hlp-test1 at 0105 display hlp-test2 at 0205 display hlp-test3 at 0305 display hlp-test4 at 0405 perform enabled-check perform get-userAccountControl perform get-pwdExpireDate display oEnabled at 0505 modify adoRecordset @MoveNext() inquire adoRecordset @EOF in adoConnState compute counter = counter + 1 display counter at 2510 end-perform. *** Close connection modify adoRecordset @Close(). destroy adoRecordset. destroy adoCommand. modify adoConnection @Close(). destroy adoConnection. main-disconnected. accept omitted tab. stop run. main-ende. exit. main-e. ***********************************************************
in @fields::@item
("msDS-UserPasswordExpiryTimeComputed")::value
in hlp-test4
I should receive for my user for example the value: 133494369554492556
But i get only 7624
I tried several things.
Cause it is an integer8 value it should be declared as s9(18) comp-5 but here is also the value 7624.
Has anyone an idea how to get here the correct value? Or what 7624 is, that i can work with this value?
Regards David Neidinger