vb and securecomputingCom2000-SafeWord-UserID, in the Scripting / Automation forum on BrianMadden.com
Brian Madden Logo
Your independent source for desktop virtualization, consumerization, and enterprise mobility management.

vb and securecomputingCom2000-SafeWord-UserID, in the Scripting / Automation forum on BrianMadden.com

rated by 0 users
This post has 10 Replies | 1 Follower

Not Ranked
Points 100
Jos Embregts Posted: Fri, Dec 14 2007 2:57 AM
In vb script objMember.securecomputingCom2000-SafeWord-UserID is not working. How can I retreive token information from Active Directory?
  • | Post Points: 20
Top 500 Contributor
Points 453
I am not sure I understand your question.

objMember could be any kind of object. If it is an AD object then securecomputingCom2000-SafeWord-UserID would have be a schema ext as that is not a standard attribute.

What is your goal?
Brandon Shell [MVP]
a.k.a BSonPosh

Note: If you want help learning Powershell or your struggling with some concepts... feel free to contact me through a post or my blog. I spend what time I have helping you learn. I do think I should be clear... I want to help you LEARN... not do your job for you. I will NOT simply write scripts for you if I do not think you wish to learn. I will spend hours if I think I can help you learn... I will not waste 5mins if I think your just want an easy way out.
  • | Post Points: 20
Not Ranked
Points 100
Here is the script, so it explains more I hope.

--------------------------------------------------------------------

'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 3.0
'
' NAME: ADExport.vbs
'
' AUTHOR: Jos Embregts
' DATE : 06-12-2007
'
' COMMENT: Extract User information from Active Directory
'
'==========================================================================

Dim ObjWb
Set ObjExcel = CreateObject("Excel.Application")

iSheetsPerBook = ObjExcel.SheetsInNewWorkbook
ObjExcel.SheetsInNewWorkbook = 5
Set objBook = ObjExcel.Workbooks.Add
ObjExcel.SheetsInNewWorkbook = iSheetsPerBook

Directory = "C:\Beheer\Rapportage users_tokens\"
FileName = "_Test_Users_.xls"
DateString = year(date()) & right("0" & month(date()),2) & right("0" & day(date()),2)

Dim x, f

Set objUitDienst = GetObject("LDAP://OU=SomeName,OU=Users,OU=Company Unie,DC=ad,DC=intra")



Call ExcelUitDienst("Blad5") ' Sub to make Excel Document, depending on language (Sheet1, Blad1)

x = 1

Call enummembers(objUitDienst)
Sub enumMembers(objUitDienst)
On Error Resume Next

For Each objMember In objUitDienst ' go through the collection
If ObjMember.Class = "user" Then ' if not User object, move on.
x = x +1 ' counter used to increment the cells in Excel

' I set AD properties to variables so if needed you could do Null checks or add if/then's to this code
' this was done so the script could be modified easier.

SamAccountName = ObjMember.samAccountName
FirstName = objMember.GivenName
LastName = objMember.sn
CN = ObjMember.CN
LastLogin = objMember.LastLogin
Token = objMember.securecomputingCom2000-SafeWord-UserID

' Write the values to Excel, using the X counter to increment the rows.

objwb.Cells(x, 1).Value = FirstName
objwb.Cells(x, 2).Value = LastName
objwb.Cells(x, 3).Value = CN
objwb.Cells(x, 4).NumberFormat = "@" 'Save the value as text
objwb.Cells(x, 4).Value = SamAccountName
objwb.Cells(x, 5).Value = LastLogin
objwb.cells(x, 6).Value = Token

' Blank out Variables in case the next object doesn't have a value for the property

SamAccountName = "-"
FirstName = "-"
LastName = "-"
Cn = "-"
Name = "-"
LastLogin = "-"
Token = "-"
End If

' If the AD enumeration runs into an OU object, call the Sub again to itinerate

If objMember.Class = "organizationalUnit" or ObjMember.Class = "container" Then
enumMembers (objMember)
End If
Next
End Sub

Sub ExcelUitDienst(shtName) ' This sub creates an Excel worksheet and adds Column heads to the 1st row
Set objwb = objExcel.ActiveWorkbook.Worksheets(shtName)
Objwb.Name = "Uit_Dienst" ' name the sheet
objwb.Activate
ObjExcel.Visible = True
objwb.Cells(1, 1).Value = "First Name"
objwb.Cells(1, 2).Value = "Last Name"
objwb.Cells(1, 3).Value = "Name"
objwb.Cells(1, 4).Value = "Account Name"
objwb.Cells(1, 5).Value = "Last Login"
objwb.cells(1, 6).Value = "Token"

'formatting for header
Set objRange = objExcel.Range("A1","F1")
objRange.Interior.ColorIndex = 33
objRange.Font.Bold = True
objRange.Font.Underline = True
End Sub

'autofit the output
Set objRange = objwb.UsedRange
objRange.EntireColumn.Autofit()

Objwb.SaveAs(Directory & DateString & FileName)
ObjExcel.Quit
MsgBox "End Extraction from AD" ' show that script is complete

-------------------------------------------------------------------------

With This Script the cells "Token" stays empty.
  • | Post Points: 35
Top 500 Contributor
Points 453
securecomputingCom2000-SafeWord-UserID is schema extension added by SafeWord RemoteAccess.
http://www.securecomputing.com/index.cfm?skey=1281

Are you using SafeWord? I did you apply the schema extensions? Do see the value using LDP.exe or ADSIedit.msc provide by support tools?
Brandon Shell [MVP]
a.k.a BSonPosh

Note: If you want help learning Powershell or your struggling with some concepts... feel free to contact me through a post or my blog. I spend what time I have helping you learn. I do think I should be clear... I want to help you LEARN... not do your job for you. I will NOT simply write scripts for you if I do not think you wish to learn. I will spend hours if I think I can help you learn... I will not waste 5mins if I think your just want an easy way out.
  • | Post Points: 20
Not Ranked
Points 100
Yes whe are using Safeword. Yes the schema extensions are added. In a commandbox with

csvde.exe -d "OU=Service Desk,OU=Gebruikers,OU=Arbo Unie Beheer,DC=ad,dc=intra" -r objectClass=User -l "name,sn,GivenName,sAMAccountName,securecomputingCom2000-SafeWord-UserID" -f "C:\Beheer\Rapportage users_tokens ArboUnie\servicedesk.csv"

it is working okay. I guess the problem is in vb because of the "-" signs.
  • | Post Points: 20
Not Ranked
Points 20
"I guess the problem is in vb because of the "-" signs."

Yes, Excel changes "x-z" to "x - z" causing an error :-(



Any idea how to avoid this ??



Regards
  • | Post Points: 20
Not Ranked
Points 25
Hey Ojgaard,

Did you ever get your script to work, since I could really use something like this :)

Regards..
  • | Post Points: 5
Not Ranked
Points 100
Solution: objMember.[securecomputingCom2000-SafeWord-UserID] (brackets)

  • | Post Points: 5
Not Ranked
Points 100
Solution: objMember.[securecomputingCom2000-SafeWord-UserID] (brackets)

  • | Post Points: 20
Not Ranked
Points 5

how do i use this script to find out the last time that the token was used for each user?? i have spent days trying to figure it out.... everything populates fine but it gives me the last login time and date for the computer rather then that last logintime for the tokens use.

 

Any help would be greatly appreciated.

 

Thanks

  • | Post Points: 5
Page 1 of 1 (10 items) | RSS