Autoprovision 3cx Windows App - Different LAN

Status
Not open for further replies.

tobias111

Forum User
Joined
Sep 2, 2019
Messages
6
Reaction score
0
Hi guys,

I know this has been discussed in other posts and all the info in https://www.3cx.com/community/threads/documentation-on-automatic-provisioning.19032/ has been really helpful, however I'm hitting an issues I just can't seem to resolve.

I've created a batch file (below, please don't judge, I hate batch files) that will automatically fill in the users 3cxVoipPhone.ini config.

The issue I'm getting is that the phone does not connect when loading the 3cx application, looking at the account settings I can see that the "3CX Tunnel local IP of remote PBX" is configured, this seems to be stopping my phone from registering, even though the option is deselected - Attachment yFfI34x.png

If I remove the profile and manually fill in the exact same information, the "3CX Tunnel local IP of remote PBX" value is empty and the phone provisions successfully. When I look at the profile again I can see the "3CX Tunnel local IP of remote PBX" has a value however it's still deselected, but the phone is completely registered - Attachment engWs5E.png

I still need to tweak some of the below (such as service password as I didn't realise this was the web login password) but the logic is all there.

Has anyone else seen this issue at all?
 

Attachments

  • engWs5E.png
    engWs5E.png
    49.4 KB · Views: 12
  • yFfI34x.png
    yFfI34x.png
    20.1 KB · Views: 12
@admins, I can't seem to post my code here. Do I need it to be reviewed?
 
3cx.bat

Code:
@ECHO OFF

cls


echo.

echo Retrieving user information

echo.


REM Perform a DSQUERY against the logged in account name and get the value

REM Remove the first line and pipe to a new file

REM Delete the old temp file

REM Remove any whitespace and assign to the extension vairable

REM Rename the variable to something useful

dsquery * "OU=YOURVALUEHERE,DC=YOURVALUEHERE,DC=YOURVALUEHERE,DC=YOURVALUEHERE" -filter "(samaccountname=%USERNAME%)" -attr x-extensionNumber >> exttmp1.txt

more +1 "exttmp1.txt" > "exttmp2.txt"

del "exttmp1.txt"

for /f "delims=" %%a in ('more exttmp2.txt') do @set tmpextension=%%a

set extension=%tmpextension: =%

del "exttmp2.txt"


dsquery * "OU=YOURVALUEHERE,DC=YOURVALUEHERE,DC=YOURVALUEHERE,DC=YOURVALUEHERE" -filter "(samaccountname=%USERNAME%)" -attr givenName >> gnametmp1.txt

more +1 "gnametmp1.txt" > "gnametmp2.txt"

del "gnametmp1.txt"

for /f "delims=" %%a in ('more gnametmp2.txt') do @set tmpgname=%%a

set trimgname=%tmpgname: =%

del "gnametmp2.txt"


dsquery * "OU=YOURVALUEHERE,DC=YOURVALUEHERE,DC=YOURVALUEHERE,DC=YOURVALUEHERE" -filter "(samaccountname=%USERNAME%)" -attr sn >> snametmp1.txt

more +1 "snametmp1.txt" > "snametmp2.txt"

del "snametmp1.txt"

for /f "delims=" %%a in ('more snametmp2.txt') do @set tmpsname=%%a

set trimsname=%tmpsname: =%

del "snametmp2.txt"


set "fullname=%trimgname% %trimsname%"


dsquery * "OU=YOURVALUEHERE,DC=YOURVALUEHERE,DC=YOURVALUEHERE,DC=YOURVALUEHERE" -filter "(samaccountname=%USERNAME%)" -attr objectGUID >> tmpauthid1.txt

more +1 "tmpauthid1.txt" > "tmpauthid2.txt"

del "tmpauthid1.txt"

for /f "delims=" %%a in ('more tmpauthid2.txt') do @set tmpauthid=%%a

set authidtest=%tmpauthid: =%

del "tmpauthid2.txt"

echo %authidtest% >> authid1.txt

for /f "delims=}" %%a in ('more authid1.txt') do @set authid1=%%a

del "authid1.txt"

echo %authid1% >> authid2.txt

for /f "delims={" %%a in ('more authid2.txt') do @set authid2=%%a

del "authid2.txt"


SET authid2

CALL :LoCase authid2

SET authid2

GOTO:configureauthid


:configureauthid

for /f "delims=" %%a in ('echo %authid2:~0,4%') do @set authidpart1=%%a

for /f "delims=" %%a in ('echo %authid2:~9,4%') do @set authidpart2=%%a

for /f "delims=" %%a in ('echo %authid2:~29,4%') do @set authidpart3=%%a

set "fullid=%authidpart1%%authidpart2%%authidpart3%UPPER"

GOTO:configureauthpwd



:configureauthpwd

dsquery * "OU=YOURVALUEHERE,DC=YOURVALUEHERE,DC=YOURVALUEHERE,DC=YOURVALUEHERE" -filter "(samaccountname=%USERNAME%)" -attr objectSid >> tmpauthpwd1.txt

more +1 "tmpauthpwd1.txt" > "tmpauthpwd2.txt"

del "tmpauthpwd1.txt"

for /f "delims=" %%a in ('more tmpauthpwd2.txt') do @set tmpauthpwd=%%a

set authpwd1=%tmpauthpwd: =%

del "tmpauthpwd2.txt"


for /f "delims=" %%a in ('echo %authpwd1:~0,1%') do @set authpwdpart1=%%a

for /f "delims=" %%a in ('echo %authpwd1:~38,6%') do @set authpwdpart2=%%a

set "fullpwd=%authpwdpart1%%authpwdpart2%UPPER%USERNAME%"



GOTO:configure3cx


:configure3cx

echo.--------------------------------

echo CallerID : %fullname%

echo Extension: %extension%

echo.--------------------------------

echo.

echo.

echo If prompted, click "Run" to allow the program to install

echo.

echo.

echo.

echo.

echo Customizing phone settings for extension %fullname%

echo.

REM mkdir "c:%HOMEPATH%\locals~1\applic~1\3CX VoIP Phone"

echo [Profile0] > "%LOCALAPPDATA%\3CX VoIP Phone\3CXVoipPhone.ini"

echo Name=%extension% >> "%LOCALAPPDATA%\3CX VoIP Phone\3CXVoipPhone.ini"

echo AuthUser=%extension% >> "%LOCALAPPDATA%\3CX VoIP Phone\3CXVoipPhone.ini"

echo AuthID=%fullid% >> "%LOCALAPPDATA%\3CX VoIP Phone\3CXVoipPhone.ini"

echo AuthPass=%fullpwd% >> "%LOCALAPPDATA%\3CX VoIP Phone\3CXVoipPhone.ini"

echo CallerID=%fullname% >> "%LOCALAPPDATA%\3CX VoIP Phone\3CXVoipPhone.ini"

echo PBXVoicemail=6%extension% >> "%LOCALAPPDATA%\3CX VoIP Phone\3CXVoipPhone.ini"

type X:\software\3CXVoipPhone.txt >> "%LOCALAPPDATA%\3CX VoIP Phone\3CXVoipPhone.ini"

goto end


:noarg

echo.

echo We were unable to extract the telephone extension for username %fullname%

echo.



:LoCase

:: Subroutine to convert a variable VALUE to all lower case.

:: The argument for this subroutine is the variable NAME.

FOR %%i IN ("A=a" "B=b" "C=c" "D=d" "E=e" "F=f" "G=g" "H=h" "I=i" "J=j" "K=k" "L=l" "M=m" "N=n" "O=o" "P=p" "Q=q" "R=r" "S=s" "T=t" "U=u" "V=v" "W=w" "X=x" "Y=y" "Z=z") DO CALL SET "%1=%%%1:%%~i%%"

GOTO:EOF


:end
 
I'll drop my .sh script in as well for anyone that's trying to implement this in a strange samba environment as well (this is run on the domain controller). This is so I can import all the users into 3cx as a .csv.


Code:
#!/bin/bash


# Get all users and groups in the IHLAndExtGroup OU, this is their full CN which is used later on as $i


for i in `ldbsearch -H /var/lib/samba/private/sam.ldb -b "OU=YOURVALUEHERE,DC=YOURVALUEHERE,DC=YOURVALUEHERE,DC=YOURVALUEHERE" gidNumber=* dn | grep ^dn | sed -e 's/dn:\ //g'`


        do :


# This uses the users full CN as the search base. In the first line it looks for anything with 'displayName' at the start of the file and does some sed substitutions to pull back just the users full na

me


        firstname=`ldbsearch -H /var/lib/samba/private/sam.ldb -b $i | grep ^givenName | sed -e 's/givenName:\ //g'`

        lastname=`ldbsearch -H /var/lib/samba/private/sam.ldb -b $i | grep ^sn | sed -e 's/sn:\ //g'`

        extension=`ldbsearch -H /var/lib/samba/private/sam.ldb -b $i | grep ^x-extensionNumber | sed -e 's/x-extensionNumber:\ //g'`

        email=`ldbsearch -H /var/lib/samba/private/sam.ldb -b $i | grep ^mail | sed -e 's/mail:\ //g'`

        authid1=`ldbsearch -H /var/lib/samba/private/sam.ldb -b $i | grep ^objectGUID | sed -e 's/objectGUID:\ //g' | cut -b 1-4,10-13,30-34`

        authid2=IFA

        authid=`printf "$authid1$authid2"`

        authpass1=`ldbsearch -H /var/lib/samba/private/sam.ldb -b $i | grep ^objectSid | sed -e 's/objectSid:\ //g' | cut -b 1,39-44`

        authpass2=`ldbsearch -H /var/lib/samba/private/sam.ldb -b $i | grep ^sAMAccountName | sed -e 's/sAMAccountName:\ //g'`

        authpass=`printf "$authpass1$authid2$authpass2" # | sed -e 's/\ //g'`

        svcpass=Super^3cx-Passw0rd


        printf "$extension,$firstname,$lastname,$email,,$authid,$authpass,,0,0,,0,1,1,0,4225,0,0,1,,,0,1,1,0,0,0,,0,0,0,0,0,0,0,0,0,1,0,0,,,1,0,0,0,,0,$authpass,$svcpass,0,0,0,,,,,0,1,,1,0,\n" >> 3cx_c

onfig.csv

        done


sed -i '1s/^/Number,FirstName,LastName,EmailAddress,MobileNumber,AuthID,AuthPassword,WebMeetingFriendlyName,WebMeetingPrivateRoom,ClickToCall,ClickToCallFriendlyName,WebMeetingAcceptReject,EnableVoicem

ail,VMNoPin,VMPlayCallerID,PIN,VMPlayMsgDateTime,VMEmailOptions,QueueStatus,OutboundCallerID,SIPID,DeliverAudio,SupportReinvite,SupportReplaces,EnableSRTP,ManagementAccess,ReporterAccess,WallboardAcces

s,TurnOffMyPhone,HideFWrules,CanSeeRecordings,CanDeleteRecordings,RecordCalls,CallScreening,EmailMissedCalls,Disabled,DisableExternalCalls,AllowLanOnly,BlockRemoteTunnel,PinProtect,MAC_0,InterfaceIP_0,

UseTunnel,DND,UseCTI,StartupScreen,HotelModuleAccess,DontShowExtInPHBK,DeskphoneWebPass,SrvcAccessPwd,VoipAdmin,SysAdmin,SecureSIP,PhoneModel14,PhoneTemplate14,CustomTemplate,PhoneSettings,AllowAllReco

rdings,PushExtension,Integration,AllowOwnRecordings,RecordExternalCallsOnly,DID\n/' 3cx_config.csv


Thanks in advance.
 
I can't seem to post my 3cx.txt config, but it's all deafult with the tunnel values empty.
 
Has anyone been able to get something similar working?
 
Status
Not open for further replies.

Forum statistics

Threads
111,933
Messages
589,812
Members
164,808
Latest member
jsbjsb