How can I Ignore a null value

From: Roger (hainesr3_at_nationwide.com)
Date: 03/19/04


Date: Fri, 19 Mar 2004 10:49:32 -0600

I've got a script that is change user properties in AD. See code below. These changes are being made based on info from a spread***. Thanks to Richard Mueller!! Anyway. The issue that I'm having, amongst other things, is that some values in the spread*** are blank. The Users Initial, for instance.

So when that happens my script reports a failure of "User may already exist". I realize that this is a matter of my poor error handling. I would like
to make it so that the script will report which property fails instead of reporting an overall failure of the conversion of the user. I hope based on my script,
someone can help me.

Thanks,

Roger

Do While obj***.Cells(intRow, 1).Value <> ""
  strUserDN = Trim(obj***.Cells(intRow, 1).Value)
  strUserCN = Trim(obj***.Cells(intRow, 2).Value)
  strUserOU = Trim(obj***.Cells(intRow, 3).Value)
  strUPN = Trim(obj***.Cells(intRow, 4).Value)
  strSAM = Trim(obj***.Cells(intRow, 5).Value)
  strGivenName = Trim(obj***.Cells(intRow, 6).Value)
  strInitials = Trim(obj***.Cells(intRow, 7).Value)
  strLastName = Trim(obj***.Cells(intRow, 8).Value)
  strAssignedID = Trim(obj***.Cells(intRow, 10).Value)
  strMailCode = Trim(obj***.Cells(intRow, 11).Value)
  strJobTitle = Trim(obj***.Cells(intRow, 12).Value)
  strStreet = Trim(obj***.Cells(intRow, 16).Value)
  strCity = Trim(obj***.Cells(intRow, 17).Value)
  strState = Trim(obj***.Cells(intRow, 18).Value)
  strZip = Trim(obj***.Cells(intRow, 19).Value)
  
  If strUserDN <> "" Then
    On Error Resume Next
    Err.Clear
    Set objUser = GetObject("LDAP://" & strUserDN)
      If Err.Number <> 0 Then
        Err.Clear
        strErr = "3" & "User Couldn't be updated " & strUserDN
        strErrReason = "User Not Found"
        strErrCode = Err.Number
      Else
    
    objUser.Put "userPrincipalName", strAssignedID & "@test.local"
 objUser.Put "sAMAccountName", strAssignedID
 objUser.Put "givenName", strGivenName
 objUser.Put "initials", strInitials
 objUser.Put "sn", strLastName
 objUser.Put "displayName", strLastName & ", " & strGivenName & " " & strInitials
 objUser.Put "physicalDeliveryOfficeName", strMailCode
 objUser.Put "mail", strAssignedID & "@nationwide.com"
 objUser.Put "streetAddress", strStreet
 objUser.Put "l", strCity
 objUser.Put "st", strState
 objUser.Put "postalCode", strZip
 
 On Error Resume Next
Err.Clear
objUser.SetInfo
If Err.Number <> 0 Then
  ' Error raised, alert and skip this entry.
  strErr = "2" & "can't be created"
  strErrReason = "User may already exist"
  strErrCode = Err.Number

Else
  ' No error, continue and assign other attributes.
  strErr = "1" & "User " & strSAM & " ---> successfully changed To ---> " & strAssignedID
  strErrReason = "Done"
  strErrCode = Err.Number
  
  'Rename the home directory for user that is successfully modified.
  'objFSO.MoveFolder "C:\TestHome\" & strSAM , "C:\TestHome\" & strAssignedID
  
  On Error GoTo 0
        
End If
 
       
    Set objOU = GetObject("LDAP://" & strUserOU)
    objOU.MoveHere "LDAP://" & strUserDN , "cn=" & strAssignedID
        
      End If
  End If

objFile.WriteLine strUserCN & "^" & strErr & "^" & strErrReason & "^" & strErrCode

intRow = intRow + 1
  
Loop