internal override void setObjectProperties(DbConnection connection, Dictionary <string, object> values) { this.ExtendedProperties = ExtendedProperties.Where(ep => ep.Level1Object == this.PrincipalName && ep.Level1Type == "USER").ToList(); if (string.IsNullOrEmpty(this.LoginName)) { this.AuthenticationType = AuthenticationType.NONE; } else { switch (this.PrincipalType) { case PrincipalType.SQLUser: this.AuthenticationType = AuthenticationType.INSTANCE; break; case PrincipalType.WindowsUser: this.AuthenticationType = AuthenticationType.WINDOWS; break; } } if (string.IsNullOrEmpty(this.DefaultSchema)) { this.DefaultSchema = "dbo"; } Database.Principals.Add(this); // TODO: /* * * if (_is2000OrLess) * { * foreach (var role in principals.Where(dp => dp.PrincipalType == PrincipalType.DatabaseRole)) * { * cmd.CommandText = string.Format("exec sp_helprolemember [{0}]", role.PrincipalName); * * using (var rdr = cmd.ExecuteReader()) * { * if (rdr.HasRows) * { * while (rdr.Read()) * { * var child = principals.FirstOrDefault(p => p.PrincipalName == rdr["MemberName"].ToString()); * if (child == null) continue; * role.ChildMembers.Add(child); * } * } * rdr.Close(); * } * } * } * else * { * cmd.CommandText = @" * select drb.role_principal_id as RolePrincipalID, drb.member_principal_id as MemberPrincipalID * from sys.database_role_members drb * "; ; * using (var rdr = cmd.ExecuteReader()) * { * if (rdr.HasRows) * { * while (rdr.Read()) * { * var parent = principals.FirstOrDefault(p => p.PrincipalID == (int)rdr["RolePrincipalID"]); * var child = principals.FirstOrDefault(p => p.PrincipalID == (int)rdr["MemberPrincipalID"]); * if (child == null || parent == null) continue; * parent.ChildMembers.Add(child); * } * } * rdr.Close(); * } * } * return principals; */ }