|
Thank you randprin.
I'm trying to do directorySearch.FindAll(); and I can't seem to get results?
I thought I'd be able to get a count and use a for statement, but when I'm debugging I cannot seem to display any values while paused over directorySearch.FindAll() and hovering over it with the mouse? Do you have any ideas?
Under FindOne(), I'll see 77 properties, but I'm coming up empty with the FindAll() .
modified 24-May-12 15:57pm.
|
|
|
|
|
Here is what I ended up using in case this comes up in a search (you'll have to change the txtbox stuff to fit your gui or console app
using (var rootDirectory = new DirectoryEntry("LDAP://" + domain))
{
using (var directorySearch = new DirectorySearcher(rootDirectory))
{
if (tBoxPin.Text != "")
{
directorySearch.Filter = string.Format("(|(sAMAccountName={0}))", tBoxPin.Text);
}
if (tBoxLastName.Text != "")
{
directorySearch.Filter = string.Format("((sn={0}))", tBoxLastName.Text);
}
if (tBoxEmail.Text != "")
{
directorySearch.Filter = string.Format("((mail={0}))", tBoxEmail.Text);
}
var result = directorySearch.FindOne();
if (tBoxLastName.Text != "")
{
SearchResultCollection searchResults = directorySearch.FindAll();
foreach (SearchResult searchResult in searchResults)
{
foreach (string propertyKey in searchResult.Properties.PropertyNames)
{
ResultPropertyValueCollection valueCollection = searchResult.Properties[propertyKey];
ResultPropertyValueCollection accountCollection = searchResult.Properties["userprincipalname"];
foreach (Object propertyValue in valueCollection)
{
if (propertyKey == "name")
{
lastNames.Add(propertyValue.ToString());
if (tBoxLastName.Text != "")
{
tBoxDomains.Text += (propertyValue.ToString()) + " - ";
foreach (Object account in accountCollection)
{
tBoxDomains.Text += account.ToString() + System.Environment.NewLine;
}
}
}
}
}
}
}
if (lastNames.Count > 1)
{
return;
}
if (result != null)
{
DirectoryEntry myDirectoryEntry = result.GetDirectoryEntry();
ResultPropertyCollection myResultPropColl;
myResultPropColl = result.Properties;
foreach (string myKey in myResultPropColl.PropertyNames)
{
if ((myKey == "samaccountname"))
{
foreach (Object myCollection in myResultPropColl[myKey])
{
tBoxPin.Text = (myCollection.ToString());
}
}
if ((myKey == "name"))
{
foreach (Object myCollection in myResultPropColl[myKey])
{
tBoxLastName.Text = (myCollection.ToString());
}
}
if ((myKey == "mail"))
{
foreach (Object myCollection in myResultPropColl[myKey])
{
tBoxEmail.Text = (myCollection.ToString());
}
}
if ((myKey == "name"))
{
foreach (Object myCollection in myResultPropColl[myKey])
{
tBoxTopSecret.Text = (myCollection.ToString().ToUpper());
}
}
if ((myKey == "homemdb"))
{
foreach (Object myCollection in myResultPropColl[myKey])
{
int delimiter = myCollection.ToString().IndexOf(",");
string trimmed = myCollection.ToString();
trimmed = trimmed.Remove(delimiter);
trimmed = trimmed.Replace("CN=", "");
tBoxExchangeServer.Text = (trimmed);
}
}
if ((myKey == "telephonenumber"))
{
foreach (Object myCollection in myResultPropColl[myKey])
{
tBoxPhone.Text = (myCollection.ToString());
}
}
}
}
}
}
|
|
|
|
|
Hi folks,
I desparatly and urgently need your help... I need a code sample or some guidance on how to write a .Net program (preferably in C#) that used ADWS (Microsoft Active Directory Web Services) to retrieve user's information, search for users that have some active directory field set to some text, etc.
T.I.A,
Yuval.
|
|
|
|
|
|
Hi,
I've read that article too. However, it demonstrates how to use LDAP calls to access the Active Directory, a method that works fine, but slowly...
I'm interested in MS-ADWS (http://technet.microsoft.com/en-us/library/dd391908(v=ws.10).aspx[^]). I've managed already to get only some of the user's attributes (such as display name, distinguished name and few others) but I need help in implementing C# code that uses these WCF services to get more user related information as well as mechanisms for searching the AD according to a given filter.
Thanks,
Yuval.
|
|
|
|
|
Im posting this to see what people come up with in this project. I dont need help with this but am in the process of trying to figure out system.io. Ive started the project off which is a windows form with a Get Folders and Files button which then opens a FolderBrowserDialog to let you pick the directory you want to list on the listbox with its subdirectories and files.
1) How can we rename a certain directory listed in the listbox
2) How do we remove unwanted directories
3) How do we check for duplicate files or directories, and remove one)
4) How do we remove unwanted characters in directory or file names.
Feel free to add other points that we could do with this project.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace MusicProject
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnGetFolders_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
FolderBrowserDialog fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
foreach (string dir in Directory.GetDirectories(fbd.SelectedPath))
{
DirectoryInfo dInfo = new DirectoryInfo(dir);
this.listBox1.Items.Add(dInfo.Name);
}
foreach (string file in Directory.GetFiles(fbd.SelectedPath))
{
FileInfo fInfo = new FileInfo(file);
this.listBox1.Items.Add (fInfo.Name);
}
}
}
}
}
|
|
|
|
|
1)
System.IO.Directory.Move(@"C:\olddir", @"C:\newdir");
2)
System.IO.Directory.Delete(@"C:\olddir",false);
3) ??
4)
var cleanDir = (@"C:\olddir").Replace('unwantedChar',"");
System.IO.Directory.Move(@"C:\olddir",cleanDir);
|
|
|
|
|
bdeklerk wrote: Feel free to add other points that we could do with this project.
A forum-post would not be the correct place for a longer-term project. Turn it into an article, and people could collaborate.
You already have answers to the other questions, which leaves #3 for me;
bdeklerk wrote: 3) How do we check for duplicate files or directories, and remove one)
You can iterate over all files and folders, and for each item; calculate a hash (like md5) and put it in a dictionary, with the hash as the key and the path as the value. If you hit a double key, you'll know that the content of both files is the same - even if the filenames and/or timestamps on the files differ.
Good luck
Bastard Programmer from Hell
|
|
|
|
|
i created application in WPF/C#.net in window xp, but when i try to run it win 7 every time i get exception on opening crystal report form in my application, even i installed following on win 7
http://downloads.businessobjects.com/akdlm/crystalviewer/CRViewer.exe
http://downloads.businessobjects.com/akdlm/cr4vs2010/CRforVS_13_0.exe
http://downloads.businessobjects.com/akdlm/cr4vs2010/CRforVS_redist_install_64bit_13_0_3.zip
modified 23-May-12 1:48am.
|
|
|
|
|
That looks like the common 32bit-64bit problem: a 32bit application cannot load a 64bit dll, and a 64bit application cannot load a 32bit dll.
Set the target of your application to x86 (i.e. 32bit), and install the 32bit version of crystal reports also on 64bit OS.
If that does not solve the problem, provide necessary details like the error message and the code lines where the exception happens.
|
|
|
|
|
|
I have two pcl files containing logos in each. I need to merge the file into a single pcl file. Iam able to merge the same but the problem is i get the two logos one after the other. I need the two logos to appear on the same line at top of the pcl file instead of one below the other. Iam using the code below to achieve what iam getting.
public void fileMerger(string inputFile, string outputFileName,string filetype )
{
{
#region get PCL file from inputFile
String ftype = "*." + filetype;
string[] tmpfiles = Directory.GetFiles(inputFile, ftype);
#endregion get PCL file from inputFile
FileStream output = new FileStream(outputFileName, FileMode.OpenOrCreate);
#region start Processing
foreach (string tempInput in tmpfiles)
{
FileStream inputfiles = new FileStream(tempInput, FileMode.Open);
if (inputFile.EndsWith(Environment.NewLine))
{
inputFile = inputFile.TrimEnd(Environment.NewLine.ToCharArray());
}
//Library.Utils.FlashMessage("inputfiles", "read");
CopyStream(output, inputfiles);
}
#endregion start Processing
}
}
void CopyStream(Stream destination, Stream source)
{
int count;
byte[] buffer = new byte[1000000];
while ((count = source.Read(buffer, 0, buffer.Length)) > 0)
{
destination.Write(buffer, 0, count);
}
}
Please help..
modified 25-May-12 5:49am.
|
|
|
|
|
You need to modify the PCL content to make the information appear on the same line. Just copying one stream followed by the second is the same as sending them direct to the printer one after the other.
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
I am looking for a software license management tool. Any suggestions?
|
|
|
|
|
Yeah, don't waste your time and money. Every single one of them has cracks available. All you end up doing is slow down the people who want your software for free and make it harder for the people who want to pay for it to use your software.
|
|
|
|
|
Good idea!
Could you please try to convince the managers of the company where I work?
Here, it is the job of software development to enforce that the user can use only those features of the software on those computers in his organisation our sales team wants him to grant (but never will write it down in a license agreement, everything has to be accomplished by technical limitations, so the user does not exactly know what he is granted to use). And of course, development has to make sure that the user cannot manipulate that...
|
|
|
|
|
Bernhard Hiller wrote: Could you please try to convince the managers of the company where I work?
Ask them how much they want to invest. Then tell them that I can break it. How much protection do you need? Are the users the kind of person that I am? Is it a problem at all, or is it more "a good idea"? I've seen quite some companies invest in copy-protections, and it hardly ever results in more sales.
Bernhard Hiller wrote: And of course, development has to make sure that the user cannot manipulate
that...
Only things that are not on my machine will not be manipulated. Even if you'd keep the information on your server, I'd be sniffing what you're sending (using fiddler2), trying to replicate it on a different server.
Bastard Programmer from Hell
|
|
|
|
|
Eddy Vluggen wrote: Ask them how much they want to invest.
My time.
Eddy Vluggen wrote: Only things that are not on my machine will not be manipulated.
Don't tell my boss how you do that, otherwise I'll have to invent something new, and then we can repeat that some rounds...
|
|
|
|
|
Bernhard Hiller wrote: My time.
Whehe, aight, spoken like a manager. Your time equals a certain amount of money, aka "cost". Is he prepared to keep you on this task until your retirement?
Bernhard Hiller wrote: Don't tell my boss how you do that, otherwise I'll have to invent something new, and then we can repeat that some rounds...
There is no system that cannot be broken - Stuxnet[^] kind of made that clear.
The question should be how much protection do you need, against whom, and what's "reasonable". If you need the kind of protection that Microsoft has on their products, you might need to spend the same amount - and despite the registration key, the registered ownership, and the holographic seal, it's still pirated a lot. Did you install that "Windows Genuine Advantage"-thingy on your Windows machine?
Most software-vendors will be selling to other companies. That means that software is less likely to appear on The Pirate Bay - there aren't that many companies that allow you to run something like bittorrent on their computers. If the product is particularly hard to install/setup, than you might have something that's more effective than most copy-protection scheme's could be.
If your app is more public, then it might be wise to have it "compile on download" and embed a guid in there that makes it a unique application. And then embed the name of the person logged in on the website and show that in the applications title-bar. No, not hard to change the caption with a hex-editor, but it would be hard to identify the guid and change that.
There's an article[^] here on CodeProject on the subject, perhaps you could collaborate?
We used a HASP dongle[^] in the past, first parallel, then the USB-kind. It's a more expensive kind of solution that's harder to crack. If you Google a bit, you'll find that it merely takes more effort.
Bastard Programmer from Hell
|
|
|
|
|
There's a ton of them, most of which do something different that may or may not match what your requirements are. Some are going to cover the entire app as a single "feature", others will let you break up an app into seperate licensable parts, but this will also require you to design your app around the licensing system. Though, if you already have your app, it's a little late to take this approach.
Seriously, you're going to have to do the homework on this yourself. Just Google for "software licensing tools" and start going down the list.
|
|
|
|
|
Bernhard Hiller wrote: his organisation our sales team wants him to grant (but never will write it down
in a license agreement, everything has to be accomplished by technical
limitations
I would suppose that tactic opens your company up to civil judgements, in that a customer might sue based on a lack of a feature (one that I am sure is advertised promoted) but which they do not have.
And your company doesn't have the documentation to prove that they did not buy that.
Bernhard Hiller wrote: And of course, development has to make sure that the user cannot manipulate
that...
For that specific requirement customer specific builds would be one solution. If they don't have the feature then the code they have doesn't exist.
|
|
|
|
|
There are many tools available in the market which u could use to protect ur software against the piracy.
If you want to develop your own algorithm then follow following steps
1. Fetch Unique identifier for the system (Hard Disk id, cpu id, Network card number etc)
2. store this uid on the same computer (dont forget to encrypt it)
3. check the stored value every time at the startup of your software
There could be many variations for this process depending upon the type of licensing that you want to implement e.g. fixed, time based, license on activation.
Hope this will help you start going
Happy Coding
|
|
|
|
|
Amardeep Deshmukh wrote: If you want to develop your own algorithm then follow following steps 1.
Fetch Unique identifier for the system (Hard Disk id, cpu id, Network card
number etc) 2. store this uid on the same computer (dont forget to encrypt
it) 3. check the stored value every time at the startup of your software
This 'solution' accomplishes nothing....
the user takes the DVD, installs it on a new PC, then steps 1-3 are run again.
Voila - a new unauthorized copy.
If it's not broken, fix it until it is
|
|
|
|
|
Kevin,
before replying or voting you should read the comments properly!!!
I said it will start him going....
In last paragraph I did mention that there could be multiple ways of implementing it...
in your below solution as well there is one drawback...User has have a internet connectivity...So are you saying to use this software, you must have a internet access??
In that case why not to develop it as hosted site instead of as a stand alone application?
you will have control over it by providing user level access
Whats say?
Happy Coding
|
|
|
|
|
The only real way to do this is on installation send some unique PC info to your server. Then each time that copy of the software is started, compare it against what's on your sever.
If that copu is being used in more than one place, it's a pirated copy.
The only fly in the ointment is you have to build in some way for the user to move the software to a new PC. An "unregister" function of some sort.
If it's not broken, fix it until it is
|
|
|
|