Import users

AlkroAlkro Member Posts: 115
edited 2008-10-28 in SQL General
Hello,

We are installed SQL. The problem is...

We have more than 500 users in Navision. How can we create SQL users automatically? Any process to do this?

Regards

Comments

  • davmac1davmac1 Member Posts: 1,283
    You can create users in SQL Server using a script where you read the values from a table. If they are SQL users (not Windows users), you could write a NAV program to load the users in the user table (or use SQL if you are careful).
  • strykstryk Member Posts: 645
    Hi!

    This script could generate the TSQL to create the logins/user on basisi of the NAV site "Database Logins" (no Windows Logins):
    set statistics io off
    go
    
    declare @userid varchar(20), @tsql varchar(1000)
    
    declare user_cur cursor for select [User ID] from Navision.dbo."User"  -- change db name!
    open user_cur
    fetch next from user_cur into @userid
    while @@fetch_status = 0 begin
      set @tsql =
    '
    USE [master]
    GO 
    CREATE LOGIN [' + @userid + '] WITH PASSWORD = ''welcome'', CHECK_POLICY = OFF
    GO
    use [Navision]   -- change db name!
    GO
    CREATE USER [' + @userid + '] FOR LOGIN [' + @userid + ']
    GO
    '
      print @tsql
      fetch next from user_cur into @userid
    end
    close user_cur
    deallocate user_cur
    
    But caution :shock: : the default password "welcome" is assigned to ALL users, you have to assure that users are changing it ASAP! The SQL feature MUST_CHANGE and CHECK_EXPIRATION do not work with NAV!
    Jörg A. Stryk (MVP - Dynamics NAV)
    NAV/SQL Performance Optimization & Troubleshooting
    STRYK System Improvement
    The Blog - The Book - The Tool
Sign In or Register to comment.