Tuesday, November 27, 2012

Error While exporting Dbimpexp.exe in Lync

While exporting contact list using DBimpexp.exe an error occurs like below
SQL Schema Version: 59
User Data Schema Version : 21
Exporting 8037 Homed Resource(s) from database...
Error: '', hexadecimal value 0x1A, is an invalid character.
Issue :
The exporting of Lync contact list was failing after 80% of completion. So  Dbimpexp.exe was not working hence no contact list backup as such. We were completely relay on DB backup but the contact list backup is very critical to re-push the individual contact list for the users if any failure happened. We were getting a 300+ MB file which was having details till approximately 80% of user details.
Cause :
This is because there is a chance of an extra junk character entered into the contract list of a user or more. But to identify which user was having the issue is a complicated thing.
Resolution:
Step 1 :
 Get the list of all sip enabled users using Lync management shell
I took the list of all users who have enabled for sip by the below command in Powershell
Get-CsAdUser |fl Sipaddress  >> emailIDs.txt  and get the list of Sip enabled users to a notepad. Using excel tricks I have removes the string sip: .
eg: sip:user1@mydomain.com   to user1.mydomain.com and also I have removed unwanted space as well.
Note: You can use  the command get-csuser |FL windowsemailAddress  if sip URI is same as email address.

Step 2:
copy dbimpexp.exe from
C:\Program Files\Common Files\Microsoft Lync Server 2010\Support
(Path may change as per your configuration) and put it in a new folder. Copy emailIDs.txt file which we have previously generated also to the same folder .
Create a batch file with a friendly name (Me it is Backup.bat) and save it in the same folder.
Content of the Batch file is as below :


FOR /F %%i in (emailIDs.txt) do (
DBIMPEXP.EXE /hrxmlfile:UserListFolder\%%i.xml /sqlserver:YourSQLserver.yourdomain.com  /user:%%i >>CommandOutput.txt
echo %%i >>output.txt
)

This batch file will take each user from emailIDs.txt file and do an individual contact backup and put the output into a new folder named userListFolder with the username.xml format .This also append the output of the command prompt to a file named CommandOutput.txt .When ever the loop takes a user it will append the command line and then it will also append the username next to it.
By that we will get the exact user details who created the issue
Sample CommandOutput.txt file is given below

……………………………………
…………………………………..
…………………………………..
Export completed successfully.
User100@mydomain.com

SQL Schema Version: 59
User Data Schema Version : 21
Exporting 1 Homed Resource(s) from database...
100% complete.
Export completed successfully.
User102@mydomain.com

SQL Schema Version: 59
User Data Schema Version : 21
Exporting 1 Homed Resource(s) from database...
100% complete.
Export completed successfully.
User103@mydomain.com

SQL Schema Version: 59
User Data Schema Version : 21
Exporting 8037 Homed Resource(s) from database...
Error: '', hexadecimal value 0x1A, is an invalid character.
User104@mydomain.com

SQL Schema Version: 59
User Data Schema Version : 21
Exporting 1 Homed Resource(s) from database...
100% complete.
Export completed successfully.
User105@mydomain.com

So in this case User104 was creating issues.
Step 3
Now open ADSIedit and get the details on this user.and check any inappropriate details as there in all fields.
If you couldn’t find any issues,open LDP and then connect to the same computer .
Open the user who is having the issue and copy the details to the notepad .
Save the file with the name Baduser.txt.
Open a normal user who have successfully exported and copy its details aswell.
Paste it to a new notepad and save with the name GoodUser.txt.
Download any file compare software and compare gooduser.txt and baduser.txt.
(I use Beyond Compare software ,trial version is enough for one time use)

While comparing 2 files which I got from ldp ,I found the street address of the user whose backup was failing ,was having an entry like
streetAddress: <ldp: Binary blob 84 bytes>;
After opening the Street address details in ADSIEdit,I found there is a Junk Character like [-> ] which was causing the issue.I changed the same and Done !!!!!.the backup completed successfully.