Filtering Users?

EHSUserEHSUser Posts: 9
edited July 19, 2006 12:18PM in SQL Toolkit Previous Versions
Greetings,
I have been using SQL Compare for quite some time though we have just recently decided to automate the process.
We usually use the default settings with the exception of Ignoring users.
However, when I use the option Options.IgnoreUsers nothing seems to happen. The users are still included in the schema script.
The compare status still says "Reading users".
I am using the line
Dim myOptions As Options = Options.IgnoreUsers Or Options.Default Or Options.IgnorePermissions
Yet my output says
Reading users
and
CREATE USER [EHSMGR] FOR LOGIN [EHSMGR] WITH DEFAULT_SCHEMA=[dbo]
GRANT CONNECT TO [EHSMGR]
GO
in the script.

What am I doing wrong?
Thanks,
Kevin

Comments

  • Hi there,
    are you always using this var?
    there are a few places for it to be passed into. Depending on your code
    eg

    db1.Register(new ConnectionProperties("(local)", "WidgetDev"), myOptions);

    Differences differences=db1.CompareWith(db2, myOptions);

    work.BuildFromDifferences(differences, myOptions, true);

    Regions regions=work.ScriptObject(db.Tables[0], myOptions);

    Hope that helps.
    David
  • Yes, I use all of these.
    For instance,
    I use
    work.BuildFromDifferences(differences, myOptions, True)
    
    to build by script.
    But the script still has the users in it.
  • I've tried it multiple times now with different options and compared the differences between the scripts.

    Ignore Permissions seems to leave out the permissions, as it should.
    Ignore User Properties leaves out the Properties, as it should.

    But when I use IgnoreUsers I still get this line in my script:
    CREATE USER [ehsehs] FOR LOGIN [EHSMGR] WITH DEFAULT_SCHEMA=[dbo]
    GRANT CONNECT TO [ehsehs]
    GO
    

    so either I am misunderstanding what that options is supposed to do, or something is not working properly.
  • Hi there,
    Yes you are right IgnoreUsers means "Ignore users' permissions and role memberships."

    I think you want the following code
    			Differences differences=db1.CompareWith(db2, Options.Default);
    
    			foreach (Difference difference in differences)
    			{
    				
                    if (difference.ObjectIn1.ObjectType == ObjectType.User)
                    {
                        difference.Selected = false;
                    }
                    else
                    {
                        difference.Selected = true;
                    }
               }
    
    Hope that helps.
    Regards
    David
  • Yes, I think that's exactly what I need.
    Thank you
  • Hi sorry for the confusion, but more time less haste would have been good
    I should have written
    foreach (Difference difference in differences)
    			{
    				
                    if (difference.DatabaseObjectType == ObjectType.User)
                    {
                        difference.Selected = false;
                    }
                    else
                    {
                        difference.Selected = true;
                    }
    			}
    
    Please excuse my mistake...
    Regards
    David
Sign In or Register to comment.