Windows Logins

ta5ta5 Member Posts: 1,164
Hi
When we get a full backup from customer database its always a bit tedious to add the windows logins of me and all the other developers. In the end there should be a report/codeunit that adds the windows logins for some users (users can be hardcoded), including the super role.
My idea is the check the table windows login whether the login \mydomain\myuser exists or not. The problem is that in table windows login the field id is a flowfield, so I cannot set a filter on it.
A workaround was to search by sid, but I dont want to hardcode the sid. Another problem is, of course how to insert a record in table windows login, also here without knowing the sid.
Any ideas?
Thanks in advance
Thomas

Comments

  • krikikriki Member, Moderator Posts: 9,116
    You can also delete the records in the security-tables, so everyone can enter.


    On the other hand, you need to run some TSQL-script to insert the records.

    This is the code I use (if the user already exists, it gives an error and continues with the rest):
    -- insert user SA into the tables
    
    INSERT INTO [dbo].[User]
               ([User ID]
               ,[Password]
               ,[Name]
               ,[Expiration Date])
         VALUES
               ('SA'
               ,''
               ,''
               ,'1753-01-01 00:00:00.000')
    GO
    
    
    INSERT INTO [dbo].[Member Of]
               ([User ID]
               ,[Role ID]
               ,[Company])
         VALUES
               ('SA'
               ,'SUPER'
               ,'')
    GO
    
    
    -- insert group AIVEBS\NAVISION into the tables
    
    
    DECLARE @SID AS VARCHAR(100)
      = 'PUT YOUR SID HERE!!!!!';
    
    INSERT INTO [dbo].[Windows Login]
               ([SID])
         VALUES
               (@SID);
    
    INSERT INTO [dbo].[Windows Access Control]
               ([Login SID]
               ,[Role ID]
               ,[Company Name])
         VALUES
               (@SID
               ,'SUPER'
               ,'')
    GO
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ta5ta5 Member Posts: 1,164
    Hi Alain
    Thanks for your suggestion. So, the SID cannot be used to find out the userid, is it? In this case, I think I will use a NAV report wie hardcoded sid's to insert the developer users.
    Thanks.
    Thomas
Sign In or Register to comment.