Permalink
Browse files

CNCT cleanup.

  • Loading branch information...
1 parent 146b08d commit 7e1e4a1e1eb362c2c96a141a51952b23c9970f79 @cincuranet committed Sep 22, 2016
@@ -327,23 +327,20 @@ private byte[] UserIdentificationData()
WriteMultiPartHelper(result, IscCodes.CNCT_specific_data, specificData);
}
- result.WriteByte(IscCodes.CNCT_client_crypt);
- result.WriteByte(4);
- result.Write(new byte[] { 0, 0, 0, 0 }, 0, 4);
-
-#warning This the CNCT_user needed in general?
-#if !NETCORE10
- var user = Encoding.UTF8.GetBytes(Environment.UserName);
+ var user = Encoding.UTF8.GetBytes(Environment.GetEnvironmentVariable("USERNAME"));
result.WriteByte(IscCodes.CNCT_user);
result.WriteByte((byte)user.Length);
result.Write(user, 0, user.Length);
-#endif
var host = Encoding.UTF8.GetBytes(Dns.GetHostName());
result.WriteByte(IscCodes.CNCT_host);
result.WriteByte((byte)host.Length);
result.Write(host, 0, host.Length);
+ result.WriteByte(IscCodes.CNCT_client_crypt);
+ result.WriteByte(4);
+ result.Write(new byte[] { 0, 0, 0, 0 }, 0, 4);
+
result.WriteByte(IscCodes.CNCT_user_verification);
result.WriteByte(0);
@@ -123,6 +123,11 @@ public object SyncObject
}
}
+ public string UserID
+ {
+ get { return _connection.UserID; }
+ }
+
public string Password
{
get { return _connection.Password; }
@@ -233,9 +238,13 @@ protected virtual void SendAttachToBuffer(DatabaseParameterBuffer dpb, string da
{
XdrStream.Write(IscCodes.op_attach);
XdrStream.Write(0);
- if (!string.IsNullOrEmpty(Password))
+ if (!string.IsNullOrEmpty(UserID))
{
- dpb.Append(IscCodes.isc_dpb_password, Password);
+ dpb.Append(IscCodes.isc_dpb_user_name, UserID);
+ if (!string.IsNullOrEmpty(Password))
+ {
+ dpb.Append(IscCodes.isc_dpb_password, Password);
+ }
}
XdrStream.WriteBuffer(Encoding.UTF8.GetBytes(database));
XdrStream.WriteBuffer(dpb.ToArray());
@@ -363,9 +372,13 @@ protected virtual void SendCreateToBuffer(DatabaseParameterBuffer dpb, string da
XdrStream.Write(IscCodes.op_create);
#warning Some constant for default database object ID
XdrStream.Write(0);
- if (!string.IsNullOrEmpty(Password))
+ if (!string.IsNullOrEmpty(UserID))
{
- dpb.Append(IscCodes.isc_dpb_password, Password);
+ dpb.Append(IscCodes.isc_dpb_user_name, UserID);
+ if (!string.IsNullOrEmpty(Password))
+ {
+ dpb.Append(IscCodes.isc_dpb_password, Password);
+ }
}
XdrStream.WriteBuffer(Encoding.UTF8.GetBytes(database));
XdrStream.WriteBuffer(dpb.ToArray());
@@ -40,9 +40,13 @@ protected override void SendAttachToBuffer(DatabaseParameterBuffer dpb, string d
{
XdrStream.Write(IscCodes.op_attach);
XdrStream.Write(0);
- if (!string.IsNullOrEmpty(Password))
+ if (!string.IsNullOrEmpty(UserID))
{
- dpb.Append(IscCodes.isc_dpb_password, Password);
+ dpb.Append(IscCodes.isc_dpb_user_name, UserID);
+ if (!string.IsNullOrEmpty(Password))
+ {
+ dpb.Append(IscCodes.isc_dpb_password, Password);
+ }
}
dpb.Append(IscCodes.isc_dpb_utf8_filename, 0);
XdrStream.WriteBuffer(Encoding.UTF8.GetBytes(database));
@@ -53,9 +57,13 @@ protected override void SendCreateToBuffer(DatabaseParameterBuffer dpb, string d
{
XdrStream.Write(IscCodes.op_create);
XdrStream.Write(0);
- if (!string.IsNullOrEmpty(Password))
+ if (!string.IsNullOrEmpty(UserID))
{
- dpb.Append(IscCodes.isc_dpb_password, Password);
+ dpb.Append(IscCodes.isc_dpb_user_name, UserID);
+ if (!string.IsNullOrEmpty(Password))
+ {
+ dpb.Append(IscCodes.isc_dpb_password, Password);
+ }
}
dpb.Append(IscCodes.isc_dpb_utf8_filename, 0);
XdrStream.WriteBuffer(Encoding.UTF8.GetBytes(database));
@@ -78,10 +78,6 @@ private static void CreateDatabaseImpl(string connectionString, int pageSize = 4
dpb.Append(IscCodes.isc_dpb_version1);
dpb.Append(IscCodes.isc_dpb_dummy_packet_interval, new byte[] { 120, 10, 0, 0 });
dpb.Append(IscCodes.isc_dpb_sql_dialect, new byte[] { options.Dialect, 0, 0, 0 });
- if (!string.IsNullOrEmpty(options.UserID))
- {
- dpb.Append(IscCodes.isc_dpb_user_name, options.UserID);
- }
if (options.Charset.Length > 0)
{
Charset charset = Charset.GetCharset(options.Charset);
@@ -510,10 +510,6 @@ private DatabaseParameterBuffer BuildDpb(IDatabase db, FbConnectionString option
{
dpb.Append(IscCodes.isc_dpb_num_buffers, options.DbCachePages);
}
- if (!string.IsNullOrEmpty(options.UserID))
- {
- dpb.Append(IscCodes.isc_dpb_user_name, options.UserID);
- }
if (!string.IsNullOrEmpty(options.Role))
{
dpb.Append(IscCodes.isc_dpb_sql_role_name, options.Role);

0 comments on commit 7e1e4a1

Please sign in to comment.