Hey please check out the script below. I have a script that has exported CNs with attributes and I am writing a script that checks an OU to see if they've been added. If they haven't been added, I create the user and apply attributes (i.e. first name, location, etc). If the user already exists I just want to modify those attributes. Any insight is very much appreciated. Thanks!!
_________________________________________________________
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile _
("Exported_Users.txt", ForReading)
'###############################################################
'## Enter the OU that you would like to impor the users to ####
'##
'##
LDAP_NAME = information here.....
'###############################################################
Set objOU = GetObject _
("LDAP://" & LDAP_NAME)
objOU.Filter = Array("user")
Do Until objFile.AtEndOfStream
strUser = objFile.Readline
GivenName = objFile.Readline
SN = objFile.Readline
City = objFile.Readline
State = objFile.Readline
Zipcode = objFile.Readline
Telephone = objFile.Readline
Title = objFile.Readline
Department = objFile.Readline
Company = objFile.Readline
DisplayName = objFile.Readline
Mail = objFile.Readline
Break_Loop = 0
User_Added = 0
###################
Set objCheck = GetObject ("LDAP://" & strUser & "," & LDAP_NAME)
This is the problem statement. If it returns "NULL" the program dies. How to I catch the null statement and move on? Thanks!!!!!!!!!
##############################
if objCheck.sn = SN and objCheck.givenName = GivenName Then
Wscript.Echo "The User has been matched..."
User_Added = 1
End If
If User_Added = 0 Then
Wscript.echo "Name: " & strUSer
Wscript.echo "First Name: " & GivenName
Wscript.echo "Last Name: " & SN
Wscript.echo "City: " & City
Wscript.echo "State: " & State
Wscript.echo "ZipCode: " & Zipcode
Wscript.echo "Telephone: " & Telephone
Wscript.echo "Title: " & Title
Wscript.echo "Department: " & Department
Wscript.echo "Company: " & Company
Wscript.echo "DisplayName: " & DisplayName
Wscript.echo "Mail: " & Mail
End If
Loop
Wscript.Echo "All contacts have been successfully imported into: " & LDAP_NAME
_________________________________________________________
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile _
("Exported_Users.txt", ForReading)
'###############################################################
'## Enter the OU that you would like to impor the users to ####
'##
'##
LDAP_NAME = information here.....
'###############################################################
Set objOU = GetObject _
("LDAP://" & LDAP_NAME)
objOU.Filter = Array("user")
Do Until objFile.AtEndOfStream
strUser = objFile.Readline
GivenName = objFile.Readline
SN = objFile.Readline
City = objFile.Readline
State = objFile.Readline
Zipcode = objFile.Readline
Telephone = objFile.Readline
Title = objFile.Readline
Department = objFile.Readline
Company = objFile.Readline
DisplayName = objFile.Readline
Mail = objFile.Readline
Break_Loop = 0
User_Added = 0
###################
Set objCheck = GetObject ("LDAP://" & strUser & "," & LDAP_NAME)
This is the problem statement. If it returns "NULL" the program dies. How to I catch the null statement and move on? Thanks!!!!!!!!!
##############################
if objCheck.sn = SN and objCheck.givenName = GivenName Then
Wscript.Echo "The User has been matched..."
User_Added = 1
End If
If User_Added = 0 Then
Wscript.echo "Name: " & strUSer
Wscript.echo "First Name: " & GivenName
Wscript.echo "Last Name: " & SN
Wscript.echo "City: " & City
Wscript.echo "State: " & State
Wscript.echo "ZipCode: " & Zipcode
Wscript.echo "Telephone: " & Telephone
Wscript.echo "Title: " & Title
Wscript.echo "Department: " & Department
Wscript.echo "Company: " & Company
Wscript.echo "DisplayName: " & DisplayName
Wscript.echo "Mail: " & Mail
End If
Loop
Wscript.Echo "All contacts have been successfully imported into: " & LDAP_NAME