DB login criteria

navuser1navuser1 Member Posts: 1,329
Hi all,

How to restrict a db user to login in DB who is not present in the User Setup table ? I'm working in Native DB.

kindly reply.
Now or Never

Comments

  • KYDutchieKYDutchie Member Posts: 345
    If it was me, I'd set the experation date in the User table to yesterday so the login becomes expired.
    You can create a simple report/codeunit that can do that for you.

    Sample Code

    UserTable : Record of "User"
    UserSetup : Record of "User Setup"

    UserTable.RESET;
    IF UserTable.FIND('-') THEN BEGIN
    REPEAT
    IF NOT UserSetup.GET(UserTable."User ID") THEN BEGIN
    UserTable."Experation Date" := CALCDATE('<-1D>', TODAY);
    UserTable.MODIFY;
    END;
    UNTIL UserTable.NEXT = 0;
    END;

    And then on the UserSetup table OnInsert Trigger

    UserTable : Record of "User"
    IF UserTable.GET("User ID") THEN BEGIN
    UserTable."Experation Date" := 0D;
    UserTable.Modify;
    END;

    This can only be run by someone who has sufficient rights to modify the User Table.

    Hope this helps.

    Regards,

    Willy
    Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.
  • kinekine Member Posts: 12,562
    And why the user is in DB Users table, if he should have no access into the DB?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.