tldm-universe/Ardent/UV/APP.PROGS/CHANGE.DOMAIN

118 lines
3.1 KiB
Plaintext
Raw Normal View History

2024-09-09 21:51:08 +00:00
*******************************************************************************
*
* SQL catalogue DOMAIN name change tool.
*
* Module %M% Version %I% Date %H%
*
* (c) Copyright 1993 Vmark Software Inc. - All Rights Reserved
* This is unpublished proprietary source code of Vmark Software Inc.
* The copyright notice above does not evidence any actual or intended
* publication of such source code.
*
*******************************************************************************
*
* Maintenance log - insert most recent change descriptions at top
*
* Date.... GTAR# WHO Description.........................................
* 08/13/99 25549 JBG Improve user-id chacking, make NT compatable
* 08/10/99 25549 JBG Initial release of CHANGE.DOMAIN
*
*******************************************************************************
INCLUDE UNIVERSE.INCLUDE VERIFY.COM
INCLUDE UNIVERSE.INCLUDE MACHINE.NAME
argv = SYSTEM(1030)
argc = DCOUNT(argv,@FM)
BREAK OFF ;* Turn breaks off.
ASSIGN 1 TO SYSTEM(999) ;* Turn off 'Q' to quit at 'Press a Key'.
******************
** Windows NT port
**
UV.ROOT = SYSTEM(32)
**
******************
UID = SYSTEM(28)
GOSUB GETUSER
* do arguments
OLD = argv<2>
IF LEN(OLD) = 0
THEN
CALL *WRAP.PRINT("** OLD domain name is empty.",Width,0,3)
CALL *WRAP.PRINT("** CHANGE.DOMAIN OLD_domain NEW_domain.",Width,0,3)
GOTO TERMINATE
END
NEW = argv<3>
* verify if valid user
OPEN "UV_USERS" TO uvusers
ELSE
CRT "Can't Open UV_USERS"
GOTO TERMINATE
END
READ urec FROM uvusers,Uname
THEN
IF urec<1> = "YES" THEN DBA = 1 ELSE DBA = 0
END
ELSE
* Since we've already discovered that Uname is not in UV_USERS, we
* assume that Uname is prefixed by the new domain name. So we want
* to construct Oname in which the prefix is the old domain name.
IF LEN(NEW) GT 0 AND Uname[1,LEN(NEW)] EQ NEW
THEN
Oname = OLD:Uname[LEN(NEW) + 1, LEN(Uname)]
READ urec FROM uvusers,Oname
THEN
IF urec<1> = "YES" THEN DBA = 1 ELSE DBA = 0
END
ELSE
CALL *WRAP.PRINT("** '":Uname:"' or '":Oname:"' are not valid SQL user.",Width,0,3)
GOTO TERMINATE
END
END
ELSE
CALL *WRAP.PRINT("** '":Uname:"' is not a valid SQL user.",Width,0,3)
GOTO TERMINATE
END
END
CLOSE uvusers
* check for user being DBA
IF DBA = 0
THEN
CALL *WRAP.PRINT("** '":Uname:"' is not a DBA.",Width,0,3)
GOTO TERMINATE
END
CMD = OS.EXEC:" '":UV.ROOT:"/bin/mksecure -nobobo ":UV.ROOT:"/sql/catalog/"
EXECUTE CMD:"UV_USERS'"
CMD = "UPDATE UV_USERS SET NAME = '":NEW:"'||SUBSTRING(NAME FROM ":LEN(OLD)+1
CMD2 = " FOR 999) WHERE SUBSTRING(NAME FROM 1 FOR ":LEN(OLD):") = '":OLD:"';"
EXECUTE CMD:CMD2
* terminate
CMD = OS.EXEC:" '":UV.ROOT:"/bin/mksecure ":UV.ROOT:"/sql/catalog/"
EXECUTE CMD:"UV_USERS'"
GOTO TERMINATE
STOP
TERMINATE:
BREAK ON ;* Turn breaks back on.
ASSIGN 0 TO SYSTEM(999) ;* Turn on 'Q' to quit at 'Press a key'.
STOP
RETURN
GETUSER:
******************
** Windows NT port
**
Uname = OCONV(UID, "PW")
IF STATUS() # 0 THEN Uname = -1
**
******************
RETURN