/// <summary>
 /// Initializes a new instance of the <see cref="T:SqlAzManAttribute&lt;OWNER&gt;"/> class.
 /// </summary>
 /// <param name="db">The db.</param>
 /// <param name="owner">The owner.</param>
 /// <param name="attributeId">The attribute id.</param>
 /// <param name="key">The key.</param>
 /// <param name="value">The value.</param>
 /// <param name="ens">The ens.</param>
 protected internal SqlAzManAttribute(NetSqlAzManStorageDataContext db, OWNER owner, int attributeId, string key, string value, SqlAzManENS ens)
 {
     this.db          = db;
     this.owner       = owner;
     this.attributeId = attributeId;
     this.key         = key;
     this.value       = value;
     this.ens         = ens;
 }
示例#2
0
 internal SqlAzManStoreGroupMember(NetSqlAzManStorageDataContext db, IAzManStoreGroup storeGroup, int storeGroupMemberId, IAzManSid sid, WhereDefined whereDefined, bool isMember, SqlAzManENS ens)
 {
     this.db                 = db;
     this.storeGroup         = storeGroup;
     this.storeGroupMemberId = storeGroupMemberId;
     this.sid                = sid;
     this.whereDefined       = whereDefined;
     this.isMember           = isMember;
     this.ens                = ens;
 }
示例#3
0
 internal SqlAzManStore(NetSqlAzManStorageDataContext db, IAzManStorage storage, int storeId, string name, string description, byte netsqlazmanFixedServerRole, SqlAzManENS ens)
 {
     this.db          = db;
     this.storage     = storage;
     this.storeId     = storeId;
     this.name        = name;
     this.description = description;
     this.currentSid  = new SqlAzManSID(((System.Threading.Thread.CurrentPrincipal.Identity as WindowsIdentity) ?? WindowsIdentity.GetCurrent()).User).BinaryValue;
     this.netsqlazmanFixedServerRole = netsqlazmanFixedServerRole;
     this.ens = ens;
 }
 internal SqlAzManAuthorization(NetSqlAzManStorageDataContext db, IAzManItem item, int authorizationId, IAzManSid owner, WhereDefined ownerSidWhereDefined, IAzManSid sid, WhereDefined objectSidWhereDefined, AuthorizationType authorizationType, DateTime?validFrom, DateTime?validTo, SqlAzManENS ens)
 {
     this.db = db;
     this.authorizationId      = authorizationId;
     this.item                 = item;
     this.owner                = owner;
     this.ownerSidWhereDefined = ownerSidWhereDefined;
     this.sid               = sid;
     this.sidWhereDefined   = objectSidWhereDefined;
     this.authorizationType = authorizationType;
     this.validFrom         = validFrom;
     this.validTo           = validTo;
     this.ens               = ens;
 }
 internal SqlAzManStoreGroup(NetSqlAzManStorageDataContext db, IAzManStore store, int storeGroupId, IAzManSid sid, string name, string description, string lDapQuery, GroupType groupType, SqlAzManENS ens)
 {
     this.db           = db;
     this.store        = store;
     this.storeGroupId = storeGroupId;
     this.sid          = sid;
     this.name         = name;
     this.description  = description;
     this.lDapQuery    = String.IsNullOrEmpty(lDapQuery) ? String.Empty : lDapQuery;
     this.groupType    = groupType;
     this.ens          = ens;
     if (groupType != GroupType.Basic)
     {
         this.members = new Dictionary <IAzManSid, IAzManStoreGroupMember>();
     }
 }
示例#6
0
        /// <summary>
        /// Writes the event.
        /// </summary>
        /// <param name="storage">The storage.</param>
        /// <param name="message">The message.</param>
        /// <param name="type">The type.</param>
        private void WriteEvent(IAzManStorage storage, string message, EventLogEntryType type)
        {
            try
            {
                SqlAzManStorage typedStorage     = storage as SqlAzManStorage;
                bool            logOnDb          = false;
                bool            logOnEventLog    = true;
                string          connectionString = String.Empty;
                Guid            instanceGuid     = Guid.Empty;
                Guid            transactionGuid  = Guid.Empty;
                int             operationCounter = 0;
                DateTime        now = DateTime.Now;
                if (typedStorage != null)
                {
                    logOnDb          = typedStorage.LogOnDb;
                    logOnEventLog    = typedStorage.LogOnEventLog;
                    connectionString = typedStorage.db.Connection.ConnectionString;
                    instanceGuid     = typedStorage.instanceGuid;
                    transactionGuid  = typedStorage.transactionGuid;
                    operationCounter = ++typedStorage.operationCounter;
                }
                string originalMessage = message;
                if (logOnDb)
                {
                    string ENSType = "User Log";
                    if (message.StartsWith("ENS Event: ", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ENSType = message.Substring(message.IndexOf("ENS Event: ") + 11);
                        ENSType = ENSType.Substring(0, ENSType.IndexOf("\r\n"));
                        message = message.Substring(message.IndexOf("\r\n") + 2);
                        message = message.TrimStart('\r').TrimStart('\n');
                    }
                    while (message.IndexOf("\r\n\r\n") != -1)
                    {
                        message = message.Replace("\r\n\r\n", "\r\n");
                    }
                    message = message.Replace("\r\n", ";");
                    string logType;
                    switch (type)
                    {
                    case EventLogEntryType.Error: logType = "E"; break;

                    case EventLogEntryType.Warning: logType = "W"; break;

                    default:
                        logType = "I"; break;
                    }
                    NTAccount                     nta         = new NTAccount(((System.Threading.Thread.CurrentPrincipal.Identity as WindowsIdentity) ?? WindowsIdentity.GetCurrent()).Name);
                    SecurityIdentifier            sid         = (SecurityIdentifier)nta.Translate(typeof(SecurityIdentifier));
                    string                        winIdentity = String.Format("{0} ({1}", nta.Value, sid.Value);
                    NetSqlAzManStorageDataContext db          = new NetSqlAzManStorageDataContext(connectionString);
                    NetSqlAzMan.LINQ.LogTable     log         = new LogTable();
                    log.LogDateTime      = now;
                    log.WindowsIdentity  = winIdentity;
                    log.MachineName      = Environment.MachineName;
                    log.InstanceGuid     = instanceGuid;
                    log.TransactionGuid  = transactionGuid == Guid.Empty ? null : new Guid?();
                    log.OperationCounter = operationCounter;
                    log.ENSType          = ENSType;
                    log.ENSDescription   = message;
                    log.LogType          = logType;
                    db.LogTables.InsertOnSubmit(log);
                    db.SubmitChanges();
                }
                if (logOnEventLog)
                {
                    if (!EventLog.SourceExists(LoggingUtility.EVENTSOURCE))
                    {
                        EventLog.CreateEventSource(LoggingUtility.EVENTSOURCE, "Application");
                    }
                    originalMessage += String.Format("\r\nInstance Guid: {0}\r\nTransaction Guid: {1}\r\nOperation Counter: {2}", instanceGuid.ToString(), transactionGuid.ToString(), operationCounter);
                    EventLog.WriteEntry(LoggingUtility.EVENTSOURCE, originalMessage, type);
                }
            }
            catch
            {
                //Ignore if error occur during logging
            }
        }
 internal SqlAzManItemAttribute(NetSqlAzManStorageDataContext db, IAzManItem owner, int attributeId, string key, string value, SqlAzManENS ens)
     : base(db, owner, attributeId, key, value, ens)
 {
 }