Re: Application Roles ENCRYPT function Valid Password Characters

From: Chuck Hawkins (charles.hawkins_at_NOSPAMjenzabar.net)
Date: 06/29/05


Date: Wed, 29 Jun 2005 08:06:00 -0400

Incidentally, here is the ugly password generation code:

set nocount on
declare @counter int,
         @password varchar(128),
         @char char(1),
         @charindex int,
         @loop int

/* Unallowed characters:
! = 33
( = 40
) = 41
, = 40
* = 42
; = 59
? = 63
@ = 64
[ = 91
] = 93
{ = 123
} = 125
*/

select @counter = 1, @password = ''

while @counter < 2
begin
        --Restrict the password to 0-9, A-Z, and a-z
 select @loop = 1
 while @loop = 1
 begin
          select @charindex = convert(int, rand() * 254)
  if (@charindex between 65 and 90 or @charindex between 97 and 122)
    and @charindex not in (33,40,41,42,59,63,64,91,93,123,125)
    --or @charindex between 161 and 255 or @charindex between 130 AND 140
       select @loop = 0
        end

        --Accumulate characters for password string
 select @char = char(@charindex)
 select @password = @password + @char
 select @counter = @counter + 1
end

while @counter < 4
begin
        --Restrict the password to 0-9, A-Z, and a-z
 select @loop = 1
 while @loop = 1
 begin
          select @charindex = convert(int, rand() * 254)
  if (@charindex between 48 and 57 or @charindex between 65 and 90 or
@charindex between 97 and 122)
    and @charindex not in (33,40,41,42,59,63,64,91,93,123,125)
    --or @charindex between 161 and 255 or @charindex between 130 AND 140
       select @loop = 0
        end

        --Accumulate characters for password string
 select @char = char(@charindex)
 select @password = @password + @char
 select @counter = @counter + 1
end
while @counter < 5
begin
        --Restrict the password to 0-9
 select @loop = 1
 while @loop = 1
 begin
          select @charindex = convert(int, rand() * 254)
  if @charindex between 48 and 57 --or @charindex between 65 and 90 or
@charindex between 97 and 122
    and @charindex not in (33,40,41,42,59,63,64,91,93,123,125)
    --or @charindex between 161 and 255 or @charindex between 130 AND 140
       select @loop = 0
        end

        --Accumulate characters for password string
 select @char = char(@charindex)
 select @password = @password + @char
 select @counter = @counter + 1
end
while @counter < 10
begin
        -- Restrict the password to NOT 0-9, A-Z, and a-z
 select @loop = 1
 while @loop = 1
 begin
          select @charindex = convert(int, rand() * 254)
  if --@charindex between 48 and 57 or @charindex between 65 and 90 or
@charindex between 97 and 122
    --or
   (@charindex between 161 and 255 or @charindex between 130 AND 140)
    and @charindex not in (33,40,41,42,59,63,64,91,93,123,125)
       select @loop = 0
        end

        --Accumulate characters for password string
 select @char = char(@charindex)
 select @password = @password + @char
 select @counter = @counter + 1
end
while @counter < 11
begin
        --Restrict the password to 0-9
 select @loop = 1
 while @loop = 1
 begin
          select @charindex = convert(int, rand() * 254)
  if @charindex between 48 and 57 --or @charindex between 65 and 90 or
@charindex between 97 and 122
    and @charindex not in (33,40,41,42,59,63,64,91,93,123,125)
    --or @charindex between 161 and 255 or @charindex between 130 AND 140
       select @loop = 0
        end

        --Accumulate characters for password string
 select @char = char(@charindex)
 select @password = @password + @char
 select @counter = @counter + 1
end
while @counter < 129
begin
        --Restrict the password to 0-9, A-Z, and a-z
 select @loop = 1
 while @loop = 1
 begin
          select @charindex = convert(int, rand() * 254)
  if (@charindex between 48 and 57 or @charindex between 65 and 90 or
@charindex between 97 and 122
    or @charindex between 161 and 255 or @charindex between 130 AND 140)
    and @charindex not in (33,40,41,42,59,63,64,91,93,123,125)
       select @loop = 0
        end

        --Accumulate characters for password string
 select @char = char(@charindex)
 select @password = @password + @char
 select @counter = @counter + 1
end
select RTRIM(@password) AS Password

"Sue Hoegemeier" <Sue_H@nomail.please> wrote in message
news:99a4c1p6996f5mklnjbq0hhmapjunkv95u@4ax.com...
> You can find the valid characters in the books online help
> topic: Security Rules.
> You can find the topic in the index under passwords, rules
> for
>
> -Sue
>
> On Tue, 28 Jun 2005 15:49:06 -0400, "Chuck Hawkins"
> <charles.hawkins@NOSPAMjenzabar.net> wrote:
>
>>When I try to use the ODBC canonical ENCRYPT function for SP_SETAPPROLE, I
>>get an ODBC error when certain otherwise good characters are used in the
>>password. What characters are and are not allowed for passwords for
>>application roles while using the ENCRYPT function?
>>
>



Relevant Pages

  • Re: heeeeeeeeeeeeeeeellllllllllllllppppppppppppppppppppp
    ... Why is using char* a bad thing and why using sprintf a bad thing to, ... can be up to MAX_PATH characters). ... LPSTR lpMsgBuf; ... MessageBox(NULL, lpMsgBuf, "GetLastError() for ...
    (microsoft.public.vc.mfc)
  • Re: heeeeeeeeeeeeeeeellllllllllllllppppppppppppppppppppp
    ... This means that if you develop the bad habit of using char * (left over ... It usually takes me five minutes to create a Unicode version of any of my apps, ... BOOL and bool are different data types. ... can be up to MAX_PATH characters). ...
    (microsoft.public.vc.mfc)
  • Re: Char and Varchar
    ... If the maximum length is short (<= 10 characters), ... maximum length, I also use CHAR. ... I use VARCHAR if long and short ...
    (microsoft.public.sqlserver.server)
  • Re: Char and Varchar
    ... If the maximum length is short (<= 10 characters), ... maximum length, I also use CHAR. ... I use VARCHAR if long and short ...
    (microsoft.public.sqlserver.programming)
  • Re: RfD: XCHAR wordset (for UTF-8 and alike)
    ... extended to work with xchars, ... >replacing one char with another. ... before-cursor part, even for fixed-width characters. ... So, should string words ...
    (comp.lang.forth)