WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

COM - Active Directory Published Certificates Info

 Keywords:  COM Active Directory AD ADSI Published Certificate Information Info x509 Published Expiration Date userCertificate CAPICOM.Certificate ValidToDate

Question:

Hi, In the Active Directory, for each user I need to get the information of the x509 Published Certificates, (to get there get the Properties of a user then open the "Published Certificates" tab) specially the Expiration Date. I have tried to pull out the "userCertificate" attribute, but I only got a long binary string. What can I do? Any hint will be really appreciated.

Answer:

I wonder if you could write the data out to a file then use 'certutil' with the decode switch to read the data from stdout.http://technet.microsoft.com/en-us/library/cc732443(WS.10).aspx

See also: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/DOS+Get~results~from~STDOUT~-~UDF.txt

Here is a very rough example demonstrating a COM Automation approach. No guarantees it will work for you.

; Get a user certificate using one of our test server VM.
strUserPath = "LDAP://shamrock/CN=Bob Smith,CN=Users,DC=jclass,DC=org"

; Get the certificate from AD and write to a file.
objUser = ObjectGet(strUserPath)
aCert   = objUser.Get("userCertificate")
hCert   = BinaryAllocArray(aCert)
strFile = DirScript():"Temp.cer"
BinaryWrite(hCert, strFile)
BinaryFree(hCert)
objUser  = 0

; Use Certificate API to get the expiry.
objCapi = ObjectCreate("CAPICOM.Certificate")
objCapi.Load(strFile)
ToDate = objCapi.ValidToDate
objCapi = 0
FileDelete(strFile)
Message( "Certificate Valid to Date", ToDate )

Article ID:   W17522
Filename:   COM - Active Directory Published Certificates Info .txt
File Created: 2014:07:18:09:40:16
Last Updated: 2014:07:18:09:40:16