internal static bool GetFTPUserGroups(string UserName) { string usernme = FTPUser.GetMasterUser(); /// persalnumber; string pwd = FTPUser.GetMasterPwd(); string get_ldap_string = FTPUser.GetLDAPString(); string ldapstring = "LDAP://" + FTPUser.GetIPaddressString() + "/CN=FTP_ACCESS," + get_ldap_string; DirectoryEntry dsDirectoryEntry = new DirectoryEntry(ldapstring, usernme, pwd); //string s = null; XmlNodeList Users = GetUserList(); XmlNode User = ApplicationSettings.Settings.CreateElement("User"); User.Attributes.Append(ApplicationSettings.Settings.CreateAttribute("UserName")); User.Attributes.Append(ApplicationSettings.Settings.CreateAttribute("Password")); User.Attributes.Append(ApplicationSettings.Settings.CreateAttribute("RootDirectory")); User.Attributes.Append(ApplicationSettings.Settings.CreateAttribute("PermissionSet")); User.Attributes.Append(ApplicationSettings.Settings.CreateAttribute("Enabled")); Settings.DocumentElement.SelectSingleNode("UserAccount").AppendChild(User); User.Attributes[0].Value = UserName.ToUpper(); return(true); }
internal FTPClient(Socket ClientSocket) { this.ClientSocket = ClientSocket; //SubItems[1].Text = ClientSocket.RemoteEndPoint.ToString(); ClientSocket.NoDelay = false; ConnectedTime = DateTime.Now; ConnectedUser = new FTPUser(); // Report the client that the server is ready to serve. SendMessage("220 FTP Ready\r\n"); // Wait for the command to be sent by the client ClientSocket.BeginReceive(BufferData, 0, BufferData.Length, SocketFlags.None, new AsyncCallback(CommandReceived), null); }
public void button1_Click(object sender, EventArgs e) { string servername = FTPUser.GetDCString(); Collection m = new Collection(); m = FTPUser.GetUserGroups(txtUserName.Text.Trim(), txtPassword.Text.Trim()); foreach (string item in m) { try { MessageBox.Show(item.ToString(), "Vulindlela FTP Server"); } catch (Exception ex) { Interaction.MsgBox(ex.Message); } } return; }
internal void Disconnect() { if (ClientSocket != null && ClientSocket.Connected) { ClientSocket.Close(); } ClientSocket = null; if (DataListener != null) { DataListener.Stop(); } DataListener = null; ClientEndPoint = null; ConnectedUser = null; BufferData = null; Rename_FilePath = null; ApplicationSettings.FtpServer.FTPClients.Remove(this); GC.Collect(); }
internal void Disconnect() { if (ClientSocket != null && ClientSocket.Connected) { ClientSocket.Close(); } ClientSocket = null; if (DataListener != null) { DataListener.Stop(); } DataListener = null; ClientEndPoint = null; ConnectedUser = null; BufferData = null; //Rename_FilePath = null; VulindlelaFTPServer.FTPServer.FTPClients.Remove(this); GC.Collect(); }
//internal static Collection GetGroupUsers(string strGroupName) //{ // string usr = FTPUser.GetMasterUser(); /// persalnumber; // string pwd = FTPUser.GetMasterPwd(); // string get_ldap_string = FTPUser.GetAppOUContext(); // string ldapstring = "LDAP://" + FTPUser.GetIPaddressString() + "/CN=FTP_ACCESS," + get_ldap_string; // DirectoryEntry de = new DirectoryEntry(ldapstring, usernme, pwd); // DirectorySearcher ds = new DirectorySearcher(de); // Collection sbGroupUsers = null; // { // ds.PropertiesToLoad.Add("memberOf"); // try // { // SearchResultCollection dsResultColl = ds.FindAll(); // short shtCounter = 0; // if (dsResultColl == null) // { return null; } // //ResultPropertyCollection myResultPropColl; // //strUsers = dsResultColl.Properties["memberOf"].IndexOf(shtCounter).ToString(); // //sbGroupUsers.Add(strUsers.ToString().Trim()); // //sbGroupUsers.Add(ControlChars.CrLf); // foreach (string myKey in myResultPropColl.PropertyNames) // { // string tab = " "; // Console.WriteLine(myKey + " = "); // foreach (Object myCollection in myResultPropColl[myKey]) // { // Console.WriteLine(tab + myCollection); // } // } // ds.Dispose(); // de.Dispose(); // } // catch (Exception ex) // { // Interaction.MsgBox("Error in GetGroupUsers Function" + Constants.vbNewLine + ex.Message.ToString(), MsgBoxStyle.Information, "Active Directory Error"); // } // } // return sbGroupUsers; //} public static StringCollection GetFTPUsers3() { string usr = FTPUser.GetMasterUser(); /// persalnumber; string pwd = FTPUser.GetMasterPwd(); string get_ldap_string = FTPUser.GetAppOUContext(); StringCollection col = new StringCollection(); string ldapstring = "LDAP://" + FTPUser.GetIPaddressString() + "/CN=FTP_ACCESS," + get_ldap_string; try { DirectoryEntry de = new DirectoryEntry(ldapstring, usr, pwd); DirectorySearcher ds = new DirectorySearcher(de); SearchResult sr = ds.FindOne(); if (sr != null) { DirectoryEntry myde = sr.GetDirectoryEntry(); string mySearchResultPath = sr.Path; ResultPropertyCollection myResultPropColl; myResultPropColl = sr.Properties; foreach (string user in myde.Properties) { Interaction.MsgBox(user.ToString(), MsgBoxStyle.OkOnly, "System Message"); } de.Dispose(); myde.Dispose(); } else { //Console.WriteLine("The '" + myLDAPPath + "' path not found."); } } catch (Exception ex) { Interaction.MsgBox(ex.Message); } return(col); }
internal static XmlNodeList GetFTPUsers() { string usr = FTPUser.GetMasterUser(); string pwd = FTPUser.GetMasterPwd(); string get_ldap_string = FTPUser.GetAppOUContext(); string ldapstring = "LDAP://" + FTPUser.GetIPaddressString() + "/CN=FTP_ACCESS," + get_ldap_string; DirectoryEntry dsDirectoryEntry = new DirectoryEntry(ldapstring, usr, pwd); XmlNodeList UserGroups = null; SearchResultCollection dsResultCollecion = null; XmlAttribute UserAttributes = null; XmlNode User = null; int i = 0; DirectorySearcher dsSearcher = new DirectorySearcher(dsDirectoryEntry); dsSearcher.PropertiesToLoad.Add("memberOf"); try { dsResultCollecion = dsSearcher.FindAll(); if (dsResultCollecion == null) { return(null); } for (i = 0; i <= (dsResultCollecion.PropertiesLoaded.LongLength - 1); i++) { User.Value = dsResultCollecion.PropertiesLoaded[0].ToString(); User.Attributes.Append(UserAttributes); UserGroups[i].AppendChild(User); } } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } return(UserGroups); }
public static Collection GetUserGroups(string _persalnumber) { string usr = FTPUser.GetMasterUser(); string pwd = FTPUser.GetMasterPwd(); string get_ldap_string = FTPUser.GetAppOUContext(); string ldapstring = "LDAP://" + FTPUser.GetIPaddressString() + "/CN=FTP_ACCESS," + get_ldap_string; DirectoryEntry dsDirectoryEntry = new DirectoryEntry(ldapstring, usr, pwd); int bytCounter = 0; string strGroups = null; Microsoft.VisualBasic.Collection UserGroups = new Microsoft.VisualBasic.Collection(); StringBuilder sbUserGroups = new StringBuilder(); DirectorySearcher dsSearcher = new DirectorySearcher(dsDirectoryEntry); dsSearcher.PropertiesToLoad.Add("memberOf"); try { SearchResult dsResult = dsSearcher.FindOne(); if (dsResult == null) { return(null); } for (bytCounter = 0; bytCounter <= (dsResult.Properties["memberOf"].Count - 1); bytCounter++) { strGroups = dsResult.Properties["memberOf"][0].ToString(); UserGroups.Add(strGroups); } } catch (Exception) { } return(UserGroups); }