Database | Proc | Application | Created | Links |
sybsystemprocs | sp_gen_login_id ![]() | ![]() | 31 Aug 14 | Defects Dependencies |
1 2 /* Sccsid = "%Z% generic/sproc/src/%M% %I% %G%" */ 3 /* 4.8 1.1 06/14/90 sproc/src/gen_login_id */ 4 5 /* 6 ** The suid generation logic should match the suid generation logic used by 7 ** the "create login" command. This is because rep agent uses the 8 ** "create login" command to create a login on a replicated master. The suids 9 ** generated should be consistent. 10 ** Modify the suid generation logic in "create login" whenever the suid 11 ** logic in this procedure is changed. 12 */ 13 create procedure sp_gen_login_id 14 @loginame varchar(30), /* login name of the new user */ 15 @insertsuid int output /* suid corresponding to 16 ** insert slot in Syslogins 17 */ 18 as 19 20 declare @msg varchar(250), 21 @suid int, /* temp variable */ 22 @retstat int 23 24 /* suid 2 is reserved for 'probe' */ 25 if (@loginame = "probe") 26 select @insertsuid = @@probesuid 27 else 28 begin 29 30 /* Generate an appropriate suid */ 31 select @suid = max(suid) 32 from master.dbo.syslogins(index syslogins) where suid > @@probesuid 33 34 if @suid is NULL 35 begin 36 select @insertsuid = @@probesuid + 1 37 end 38 else if @suid != @@maxsuid 39 select @insertsuid = @suid + 1 40 41 else 42 begin 43 select @suid = min(suid) 44 from master.dbo.syslogins(index syslogins) where suid < - 2 45 46 if @suid is NULL 47 begin 48 select @insertsuid = - 3 49 end 50 else if @suid != @@minsuid 51 select @insertsuid = @suid - 1 52 53 /* check for holes if we already used up all suids */ 54 else 55 begin 56 /* Start looking for holes between @@minsuid and 57 ** @@maxsuid. */ 58 select @insertsuid = @@minsuid 59 while exists (select * from master.dbo.syslogins 60 (index syslogins) 61 where suid = @insertsuid) 62 begin 63 select @insertsuid = @insertsuid + 1 64 65 if (@insertsuid = @@invalidsuid) 66 begin 67 /* 68 ** Uids -2, -1, 0 and 2 are all invalid 69 */ 70 select @insertsuid = @insertsuid + 5 71 end 72 73 if @insertsuid = @@maxsuid 74 begin 75 /* 76 ** 17266, "All logins have been 77 ** assigned. No more logins can be 78 ** added at this time." 79 */ 80 raiserror 17266 81 return (1) 82 end 83 end 84 85 end 86 end 87 end 88 89 return (0) 90
exec sp_procxmode 'sp_gen_login_id', 'AnyMode' go Grant Execute on sp_gen_login_id to public go
DEFECTS | |
![]() | |
![]() | |
![]() | 25 |
![]() | 65 |
![]() | 81 |
![]() | 89 |
![]() | 32 |
![]() | 44 |
![]() | 60 |
![]() | 32 |
![]() | 20 |
![]() | 22 |
![]() | 59 |
![]() | 13 |
![]() | 13 |
![]() | 13 |
DEPENDENCIES |
PROCS AND TABLES USED reads table master..syslogins (1) ![]() CALLERS called by proc sybsystemprocs..sp_addlogin ![]() |