/// <summary> /// Get the iFolder System Policy /// </summary> /// <returns>An SystemPolicy Object</returns> public static SystemPolicy GetPolicy() { SystemPolicy props = new SystemPolicy(); Store store = Store.GetStore(); string domain = store.DefaultDomain; // space limit props.SpaceLimitUser = DiskSpaceQuota.GetLimit(domain); //ifolder limit props.NoiFoldersLimit = iFolderLimit.GetLimit(domain); // sync internval props.SyncInterval = Simias.Policy.SyncInterval.GetInterval(domain); // file size props.FileSizeLimit = FileSizeFilter.GetLimit(domain); props.EncryptionStatus = Simias.Policy.SecurityState.GetStatus(domain); // Disable sharing policy props.SharingStatus = Simias.Policy.Sharing.GetStatus(domain); // file types SystemPolicy.SplitFileTypes(FileTypeFilter.GetPatterns(domain), out props.FileTypesIncludes, out props.FileTypesExcludes); return(props); }
/// <summary> /// Get the User Policy /// </summary> /// <param name="userID">The User ID</param> /// <returns>The UserPolicy Object</returns> public static UserPolicy GetPolicy(string userID, string AdminId) { UserPolicy props = new UserPolicy(); props.UserID = userID; Store store = Store.GetStore(); Domain domain = store.GetDomain(store.DefaultDomain); Member member = domain.GetMemberByID(userID); if (member == null) { throw new UserDoesNotExistException(userID); } Access.Rights rights = (member != null) ? member.Rights : Access.Rights.Deny; props.isAdmin = (rights == Access.Rights.Admin); props.LoginEnabled = !(domain.GetLoginpolicy(userID)); // disk space DiskSpaceQuota quota = DiskSpaceQuota.Get(member); props.SpaceLimitEffective = quota.Limit; //props.SpaceUsed = quota.UsedSpace; props.SpaceUsed = Simias.Server.Catalog.GetUsedSpaceOfUserID(userID); //props.SpaceAvailable = quota.AvailableSpace; props.SpaceLimit = DiskSpaceQuota.GetLimit(member); props.SpaceAvailable = props.SpaceLimitEffective - props.SpaceUsed; props.EncryptionStatus = Simias.Policy.SecurityState.GetStatus(member); // To return disable sharing value for an user props.SharingStatus = Simias.Policy.Sharing.GetStatus(member); // file size props.FileSizeLimit = FileSizeFilter.GetLimit(member); props.FileSizeLimitEffective = FileSizeFilter.Get(member).Limit; //No of ifolders limit props.NoiFoldersLimit = iFolderLimit.Get(member).Limit; // sync interval props.SyncInterval = Simias.Policy.SyncInterval.GetInterval(member); props.SyncIntervalEffective = Simias.Policy.SyncInterval.Get(member).Interval; // file types SystemPolicy.SplitFileTypes(FileTypeFilter.GetPatterns(member), out props.FileTypesIncludes, out props.FileTypesExcludes); // file types effective SystemPolicy.SplitFileTypes(FileTypeFilter.Get(member, false).FilterUserList, out props.FileTypesIncludesEffective, out props.FileTypesExcludesEffective); props.AdminGroupRights = iFolderUser.GetAdminRights(AdminId, userID); return(props); }
/// <summary> /// Get the iFolder Policy /// </summary> /// <param name="ifolderID">The iFolder ID</param> /// <param name="accessID">The Access User ID</param> /// <param name="adminID">The logged in Admin ID</param> /// <returns>An iFolderPolicy Object</returns> public static iFolderPolicy GetPolicy(string ifolderID, string accessID, string adminID) { iFolderPolicy props = new iFolderPolicy(); props.iFolderID = ifolderID; Store store = Store.GetStore(); Collection c = store.GetCollectionByID(ifolderID); if (c == null) { throw new iFolderDoesNotExistException(ifolderID); } // impersonate iFolder.Impersonate(c, accessID); // disk space DiskSpaceQuota dsq = DiskSpaceQuota.Get(c); props.SpaceLimitEffective = dsq.Limit; props.SpaceAvailable = dsq.AvailableSpace; props.SpaceUsed = c.StorageSize; props.SpaceLimit = DiskSpaceQuota.GetLimit(c); // no syncing (locked) //props.Locked = IsLocked(c); props.Locked = c.Disabled; // sync interval props.SyncInterval = Simias.Policy.SyncInterval.GetInterval(c); props.SyncIntervalEffective = Simias.Policy.SyncInterval.Get(c).Interval; // to return the value of disable sharing policy for an iFolder props.SharingStatus = Simias.Policy.Sharing.GetStatus(c); // file types SystemPolicy.SplitFileTypes(FileTypeFilter.GetPatterns(c), out props.FileTypesIncludes, out props.FileTypesExcludes); SystemPolicy.SplitFileTypes(FileTypeFilter.Get(c, false).FilterList, out props.FileTypesIncludesEffective, out props.FileTypesExcludesEffective); // file size props.FileSizeLimit = Simias.Policy.FileSizeFilter.GetLimit(c); props.FileSizeLimitEffective = Simias.Policy.FileSizeFilter.Get(c).Limit; props.AdminGroupRights = iFolderUser.GetAdminRights(adminID, c.Owner.UserID); return(props); }
public static void GetReports( ) { //if( replace == false ) Console.WriteLine("You have opted to view and not delete..Use enable to modify also "); else Console.WriteLine("It will modify the members"); Store.Initialize(SimiasDataPath, true, -1); Store store = Store.GetStore(); if (store == null) { Console.WriteLine("store could not be initialized....."); } Domain domain = store.GetDomain(store.DefaultDomain); Console.WriteLine("**************************IFOLDER REPORT********************* "); Console.WriteLine(); Console.WriteLine(); try { ICSList ifolders = store.GetCollectionsByType("iFolder"); foreach (ShallowNode sn in ifolders) { object[] cells = new object[count]; Collection ifolder = store.GetCollectionByID(sn.ID); Member owner = domain.GetMemberByID(ifolder.Owner.UserID); Console.WriteLine(" *************"); Console.WriteLine("user name is :{0} and iFolder name is :{1}", owner.FN, ifolder.Name); Console.WriteLine("iFolder quota is :{0}", DiskSpaceQuota.GetLimit(ifolder)); Console.WriteLine("Users quota is :{0}", DiskSpaceQuota.Get(owner).Limit); Console.WriteLine(" "); } } catch (Exception ex) { Console.WriteLine(); Console.WriteLine(); Console.WriteLine(ex); Console.WriteLine(ex.StackTrace); } finally { Store.DeleteInstance(); } }
/// <summary> /// generate the report /// </summary> /// <param name="path">path where to generate</param> /// <param name="timestamp">time</param> public static void Generate(string path, DateTime timestamp) { const double MB = 1024 * 1024; string fileName = Path.Combine(path, String.Format("ifolder-{0}.csv", timestamp.ToString("yyyyMMdd-HHmmss"))); StreamWriter file = File.CreateText(fileName); try { Store store = Store.GetStore(); Domain domain = store.GetDomain(store.DefaultDomain); // headers Report.WriteHeaderRow(file, columns); // list iFolders ICSList ifolders = store.GetCollectionsByType("iFolder"); foreach (ShallowNode sn in ifolders) { object[] cells = new object[count]; Collection ifolder = store.GetCollectionByID(sn.ID); Member owner = domain.GetMemberByID(ifolder.Owner.UserID); // cells cells[(int)ColumnID.ReportTime] = timestamp; cells[(int)ColumnID.iFolderSystem] = domain.Name; cells[(int)ColumnID.iFolderServer] = "localhost"; cells[(int)ColumnID.iFolderID] = ifolder.ID; cells[(int)ColumnID.iFolderName] = ifolder.Name; cells[(int)ColumnID.iFolderSize] = ifolder.StorageSize / MB; cells[(int)ColumnID.iFolderPath] = ifolder.UnmanagedPath; cells[(int)ColumnID.iFolderQuota] = DiskSpaceQuota.GetLimit(ifolder) / MB; cells[(int)ColumnID.MemberCount] = ifolder.GetMemberList().Count; cells[(int)ColumnID.FileCount] = ifolder.GetNodesByType(NodeTypes.FileNodeType).Count; cells[(int)ColumnID.DirectoryCount] = ifolder.GetNodesByType(NodeTypes.DirNodeType).Count; cells[(int)ColumnID.OwnerID] = owner.UserID; cells[(int)ColumnID.OwnerName] = owner.FN; cells[(int)ColumnID.OwnerCN] = owner.Name; cells[(int)ColumnID.OwnerDN] = owner.Properties.GetSingleProperty("DN"); cells[(int)ColumnID.OwnerQuota] = DiskSpaceQuota.Get(owner).Limit / MB; cells[(int)ColumnID.OwnerLastLogin] = owner.Properties.GetSingleProperty("LastLogin"); cells[(int)ColumnID.OwnerDisabled] = domain.IsLoginDisabled(owner.UserID); cells[(int)ColumnID.PreviousOwner] = ifolder.PreviousOwner; cells[(int)ColumnID.OrphanedOwner] = ifolder.Properties.GetSingleProperty("OrphanedOwner"); Report.WriteRow(file, columns, cells); } } catch (Exception e) { file.WriteLine(); file.WriteLine(); file.WriteLine(e); file.WriteLine(e.StackTrace); } finally { file.Close(); } }
/// <summary> /// Generates a report /// </summary> public void GenerateReport() { bool hadException = false; const double MB = 1024 * 1024; ReportConfig config = GetReportConfiguration(); string reportPath = null; if (config.IsiFolder) { DirNode dirNode = reportCollection.GetRootDirectory(); reportPath = dirNode.GetFullPath(reportCollection); } else { reportPath = ReportPath; } string fileName = String.Format("ifolder-{0}-{1}.csv", Environment.MachineName, currentReportTime.ToString("yyyyMMdd-HHmmss")); string filePath = Path.Combine(reportPath, fileName); log.Debug("Report file name = {0}", filePath); StreamWriter file = File.CreateText(filePath); try { Domain domain = store.GetDomain(store.DefaultDomain); // headers WriteHeaderRow(file, columns); // list iFolders ICSList ifolders = store.GetCollectionsByType("iFolder"); foreach (ShallowNode sn in ifolders) { object[] cells = new object[count]; Collection ifolder = store.GetCollectionByID(sn.ID); Member owner = domain.GetMemberByID(ifolder.Owner.UserID); // cells if (cli != null) { cells[(int)ColumnID.ReportTime] = currentReportTime.ToString(cli); cells[(int)ColumnID.OwnerLastLogin] = owner.Properties.GetSingleProperty("LastLogin").ToString(cli); cells[(int)ColumnID.LastSyncTime] = ifolder.Properties.GetSingleProperty("LastModified").ToString(cli); } else { cells[(int)ColumnID.ReportTime] = currentReportTime.ToString("F"); cells[(int)ColumnID.OwnerLastLogin] = owner.Properties.GetSingleProperty("LastLogin").ToString("F"); cells[(int)ColumnID.LastSyncTime] = ifolder.Properties.GetSingleProperty("LastModified").ToString("F"); } cells[( int )ColumnID.iFolderSystem] = domain.Name; cells[( int )ColumnID.iFolderServer] = Environment.MachineName; cells[( int )ColumnID.iFolderID] = ifolder.ID; cells[( int )ColumnID.iFolderName] = ifolder.Name; cells[( int )ColumnID.iFolderSize] = ifolder.StorageSize / MB; cells[( int )ColumnID.iFolderPath] = ifolder.UnmanagedPath; cells[( int )ColumnID.iFolderQuota] = DiskSpaceQuota.GetLimit(ifolder) / MB; cells[( int )ColumnID.MemberCount] = ifolder.GetMemberList().Count; cells[( int )ColumnID.FileCount] = ifolder.GetNodesByType(NodeTypes.FileNodeType).Count; cells[( int )ColumnID.DirectoryCount] = ifolder.GetNodesByType(NodeTypes.DirNodeType).Count; cells[( int )ColumnID.OwnerID] = owner.UserID; cells[( int )ColumnID.OwnerName] = owner.FN; cells[( int )ColumnID.OwnerCN] = owner.Name; cells[( int )ColumnID.OwnerDN] = owner.Properties.GetSingleProperty("DN"); cells[( int )ColumnID.OwnerQuota] = DiskSpaceQuota.Get(owner).Limit / MB; cells[( int )ColumnID.OwnerDisabled] = domain.IsLoginDisabled(owner.UserID); cells[( int )ColumnID.PreviousOwner] = ifolder.PreviousOwner; cells[( int )ColumnID.OrphanedOwner] = ifolder.Properties.GetSingleProperty("OrphanedOwner"); WriteRow(file, columns, cells); } } catch (Exception ex) { hadException = true; file.WriteLine(); file.WriteLine(); file.WriteLine(ex); file.WriteLine(ex.StackTrace); } finally { file.Close(); if (hadException == false) { // If this is an iFolder create the file node for the report file. if (config.IsiFolder) { CreateFileNode(fileName); } // Set the time of the last successful report. SetLastReportTime(currentReportTime); } } }