|
Specify at least AuthenticationTypes.ServerBind for DirectoryEntry.AuthenticationType . According to the docs:If your ADsPath includes a server name, specify this flag when using the LDAP provider. Do not use this flag for paths that include a domain name or for serverless paths. Specifying a server name without also specifying this flag results in unnecessary network traffic. Your ADsPath includes the server name, so you must bind to the server. If you don't require write access, you might also specify AuthenticationTypes.ReadonlyServer (the AuthenticationTypes enumeration is attribute with the FlagsAttribute so you can OR themn together using | ).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks alot for the suggestions, unfortunately I had already tried the various flags with no result.
Now the rest of this post is in "thinking out loud" mode, but if anybody has a clue feel free to join in
The LDAP server I was attempting to connect to is beyond my control, so while playing around I have setup my own ldap server (OpenLdap)
Now if I run the server using the default LDAP port I can connect and retrieve data using the following paths :
string ldapPath = "LDAP://10.139.42.89:389/dc=domain,dc=com";
string ldapPath = "LDAP://10.139.42.89/dc=domain,dc=com";
I can also use the openLdap LdapSearch tool to retrieve data aswell
If I start the server using any other port, say 9898, when I attempt to retrieve data using the following path it fails :
string ldapPath = "LDAP://10.139.42.89:9898/dc=domain,dc=com";
This fails on FindAll() with "The Server is not operational"
But I can still perform searches to that port using the openLdap ldapSearch tool
So I thought that maybe the .NET framework was ignoring the port and always going to the default (389) but if I run the server on the default port and use the following connection string :
string ldapPath = "LDAP://10.139.42.89:9898/dc=domain,dc=com";
It still fails
Every single document I look at advises that ldap connection paths should be formatted in the way the ones above are, which I assume is correct as I can make connections to the default port either by specifying or not - but it doesnt explain why I cannot connect to non default ports.
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
Of course the last example is going to fail; the LDAP server isn't running on port 9898.
The questions you have to start asking yourself are about authentication more than likely. For example, when you use the OpenLDAP tools to search the directory, are you specifying any credentials or other options besides the server to bind to and the query?
Also, regardless of whether or not you're having problems, you'll still need those flags I mentioned before to bind to the server if it's in your ADsPath.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Although the authentication flags are important, I am fairly certain they are not the cause of this problem (I am currently using AuthenticationTypes.ServerBind | AuthenticationTypes.ReadonlyServer)
While testing the connection strings detail above the only changes that are made are :
- changing the port in the declaration of "ldapPath".
- changing the port that the LDAP server is listening on.
Whilst on the default port (389) everything works as it should, connections can be made and I can perform queries which return exactly what I would expect them to.
According to ldap docs changing the listen port is just that, nothing else changes so the way the C# client authenticates shouldnt need to change either.
I have also downloaded a few different ldap browsers, all of these work regardless of the port the server is listening on, and I am 101% certain I am using the correct connection details (if I wasnt I wouldnt be able to connect on the default port). There is something odd afoot here, and I will be damned if its going to beat me.
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
And as I asked before, with all these clients, what are you specifying for credentials (if any) and other options? Something is obviously different.
Also make sure that you have the latest service packs and other updates for your system. Since the Directory Services in .NET uses COM interop with native libraries, you want to make sure that those libraries don't have any bugs.
A good test would be to find a client with which to test that uses the same COM servers on your Windows system. I believe that there are some in the Windows Server Resource Kit (for 2000 and 20003). The problem may be with the COM servers, although I highly doubt it since you're not the only one who would try this.
Have you read over all the AuthenticationTypes enum member documentation? There may be other stuff you have to specify. The clients you've been trying would use necessary binding flags as well, you just probably wouldn't know about it or be able to control them (or at least all of them).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
I'm trying to write my own custom toolbar from scratch.
Now I've a problem: I created a class named coolToolBarButton which contains information about the button. Those buttons are grouped into a coolToolBarButtonCollection-Class.
I tried to add buttons to the toolbar via the designer, but it doesn't work. I clicked on the porperty field and the "coolToolBarButton Collection Editor" appeared. I was able to add some buttons, but then I clicked on the OK-Button and the buttons weren't added to the collection!
What's wrong?
Here's the code:
public class coolToolBarButton
{
private Image m_Image;
[DefaultValue(null),
System.ComponentModel.RefreshProperties(RefreshProperties.Repaint)]
public Image Image
{
get { return m_Image; }
set
{
m_Image = value;
}
}
}
public class coolToolBarButtonCollection : CollectionBase
{
public int Add(coolToolBarButton Button)
{
return List.Add(Button);
}
public void Insert(int index,coolToolBarButton Button)
{
List.Insert(index, Button);
}
public void Remove(coolToolBarButton Button)
{
List.Remove(Button);
}
public bool Contains(coolToolBarButton Button)
{
return List.Contains(Button);
}
public int IndexOf(coolToolBarButton Button)
{
return List.IndexOf(Button);
}
public void CopyTo(coolToolBarButton[] array, int index)
{
List.CopyTo(array, index);
}
public coolToolBarButton this[int index]
{
get { return (coolToolBarButton)List[index]; }
set { List[index] = value; }
}
}
///
/// Summary description for coolToolBar
///
public class coolToolBar : System.Windows.Forms.Control
{
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
private coolToolBarButtonCollection m_ButtonCollection;
public coolToolBarButtonCollection Buttons
{
get { return m_ButtonCollection; }
set
{
m_ButtonCollection = value;
}
}
.......
|
|
|
|
|
When you change the images collection, you have to Invalidate the control which will force it to repaint. I got extremely frustrated with the same problem!
|
|
|
|
|
Do you mean they don't show up on the toolbar, or that they aren't serialized to code? If you mean the latter case, you must attribute your collection property with DesignerSerializationVisibility(DesignerSerializatioVisibility.Content) (uses the DesignerSerializationVisibilityAttribute ) so that it serializes the collection to your source file. You can also override this behavior by attributing your toolbar class with a custom designer using the DesignerAttribute .
See Enhancing Design-Time Support[^] in the .NET Framework SDK for more information on the .NET component model and design-time capabilities.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
It works now! Very good!
But there's another problem: I placed my custom toolbar on the form and added some buttons. If I remove the toolbar, the single buttons don't get removed from the code!
|
|
|
|
|
This is my code:
[DesignTimeVisible(false)]
public class coolToolBarButton : Component
{
private Image m_Image;
[DefaultValue(null),
System.ComponentModel.RefreshProperties(RefreshProperties.Repaint)]
public Image Image
{
get { return m_Image; }
set
{
m_Image = value;
}
}
}
public class coolToolBarButtonCollection : CollectionBase
{
public int Add(coolToolBarButton Button)
{
return List.Add(Button);
}
public void AddRange(coolToolBarButton[] Buttons)
{
for(int i=0;i<buttons.length;++i)
list.add(buttons[i]);
="" }=""
="" public="" void="" insert(int="" index,cooltoolbarbutton="" button)
="" {
="" list.insert(index,="" button);
="" }
="" remove(cooltoolbarbutton="" list.remove(button);
="" bool="" contains(cooltoolbarbutton="" return="" list.contains(button);
="" int="" indexof(cooltoolbarbutton="" list.indexof(button);
="" copyto(cooltoolbarbutton[]="" array,="" index)
="" list.copyto(array,="" index);
="" cooltoolbarbutton="" this[int="" index]
="" get="" {="" (cooltoolbarbutton)list[index];="" set="" list[index]="value;" }
="" <summary="">
/// Summary description for coolToolBar
///
public class coolToolBar : System.Windows.Forms.Control
{
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
private coolToolBarButtonCollection m_ButtonCollection;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public coolToolBarButtonCollection Buttons
{
get { return m_ButtonCollection; }
set
{
m_ButtonCollection = value;
}
}
public coolToolBar()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
m_ButtonCollection=new coolToolBarButtonCollection();
SetStyle(ControlStyles.DoubleBuffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.ResizeRedraw |
ControlStyles.StandardDoubleClick |
ControlStyles.UserMouse |
ControlStyles.StandardClick |
ControlStyles.SupportsTransparentBackColor,
true);
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region Component Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
protected override void OnPaint(PaintEventArgs pe)
{
// TODO: Add custom paint code here
// Calling the base class OnPaint
base.OnPaint(pe);
}
}
|
|
|
|
|
I'm building an asp.net app with c# to load data from different file resources, validate it and push it into a SQL Server db. I've handled Word interop so I can pull in data from pre-defined Word documents, validate and load it. I've worked with CSV's and have no problem there.
The issue I'm having is XML, or rather XSD.
I have an XSD which I want to use to validate data imported from XML. I've tried the XSD.exe tool but it just doesn't seem to generate an accurate typed dataset, basically not all datatables I'd expect defined, are defined. Can I use an XSD file at runtime to validate XML imported using ReadXML, and if not, how else can I do this?
Any thoughts appreciated, all avenues explored...
Rhys
"When one burns one's bridges, what a very nice fire it makes" -- Dylan Thomas
"As to marriage or celibacy, let a man take the course he will. He will be sure to repent" -- Socrates
"Doh!" -- Homer Simpson
|
|
|
|
|
try using the XMLValidatingReader
|
|
|
|
|
I have a client program that talks to an IBM mainframe and recieves 64bit unsigned integers(STCK) that represent date-time values. I need to convert these to native DateTime format for use in my c# code. Anyone have or know of any conversion routines available for this purpose. If not I'll have to write my own. Thanks.
dzs
|
|
|
|
|
DateTime stores time information in ticks, or 100 ns (.0001 milliseconds). It also uses an epoch (start date) of January 1st, 0001 AD at 12:00:00 midnight (00:00:00). Using that information, you'll have to convert your STCK (most likely stored in milliseconds, as date/time types are) accordingly. There is nothing in the .NET FCL to assist you with that. You will then, of course, have to find out both the unit and epoch of the STCK data type.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
My goal is to have a control which will mimic Windows Explorer while viewing in thumbnail mode. Is there one which exisits in the .net framework?
---
I want to create a digital image manager to allow me to batch rename, rotate, resize etc...
Does something like this exist?
|
|
|
|
|
|
Thanks for the suggestion. Do you have any places I could look to see like how a Textbox is rendered to the screen so I can make my own?
|
|
|
|
|
Something I have noticed and not sure if it is a bug in the developer or what. But here is the scenerio.
1) Make webform
2) Place a Datagrid control on it
3) Add and oledbdataadapter and the dataset
4) Since The database will be pointing to the local harddrive by default I have to change the connection string. Like so:
string datapath = Server.MapPath("/bin/csharp.mdb");
this.oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ datapath;
This works fine but here is the catch.
If i change anything at all on the datagrid like for instance an event like delete
or change a property then all the sudden I no longer have an oleDbConnection at all.
It completely wipes out the code that I typed and doing a search for jet turns up nothing.
Same applies if I add an insert cause by default the datagrid control doesn't have a templated insert. I add one manually
this.DataGrid1.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.insertme);
If i change anything on the datagrid via its properties after making that code addition the line of code will be wiped out. And yes I save the code before modification.
Any ideas? Gets annoying after a while. I typed the strings about 4 times after it wiped them clean and i go heck with this and made a text file where i could cut and paste.
Win32newb
"Programming is like sex, make one mistake and you have to support it for a long time"
|
|
|
|
|
Changing anything the designer creates and uses is likely to cause such problems. If you want to continue to use the designer, I recommend that you click the Advanced [...] button under the Configuration category in the PropertyGrid while your connection is selected and add an entry for the connection string to the appSettings section of your Web.config file. This is more robust anyway. If you decide, for example, to move your .mdb out of your web application, you can easily change the connection string to reflect that. Since you're using the OLE DB client for ADO.NET, you could even change the connection string to use a different provider (provided that all your ADO.NET code would work with a different one, which is usually fine for most OLE DB providers).
The designer shouldn't complain and croak now.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
report viwer sql reporting services in code?
|
|
|
|
|
I don't have a lot of experience with SQL 2000 RS yet (we'll be looking more into it in the future when we redesign quite a bit of our codebase), but I did watch the MSDN TV video, Developing Applications Using SQL Server 2000 Reporting Services[^], and I believe this was discussed. IIRC, you can pass parameters via GET or POST data, as well as set parameters using the object model (the managed classes and their members).
More information should be available in the RS documentation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
yes i got it using the url which was easy but took some finding. I think sql reporting services very good i was getting too many bugs from crystal reports and gave up. but sql is very clean. I do need to get more info on the object way of doing it through the reporting web service. I would like to emigrate my family to the USA and good links on finding a sponser for wrok?
|
|
|
|
|
Hi,
I have a main application (Main), from which i can launch two different applications (App1 or App2). I each case i am minimizing the main (Main) application to trash. But on exiting the applications (App1) or (App2), is there any way to restore the window of the main application without double clicking on the Trash icon. I have a requirement to do so. Can somebody help me on this?
Harihara Subramanian
|
|
|
|
|
The other applications will need a reference to the switchboard. You'll either need to use .NET Remoting in order to show/hide forms or use Windows messaging. At least, those two would be the easiest ways. You could create some protocol and use a socket connection, but .NET Remoting wraps all that rather nicely.
So, if the switchboard registered a WKO (well-known object), the other applications could call remote methods on that WKO. The implementation of that object (having a reference to the main Form ) could call Show and Hide when appropriate, or change the WindowState to minimize it to the task bar (not trash, unless you're talking about some specific region within your application) or restore it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks a lot for the immediate reply. I am a little confused as the main application is a .NET application and for the rest, one writeen in VB and the other in VC++. As the intention behind this usecase is to switch to only one of the application at any instance of time.
There is an executable called 'Interoperator' written in VB to which the main application passes instruction like the context information and the application code (App1 or App2).
I have minimized the main application to the task bar(used the ShowinTaskbar property and set it to false), however i do not know how i can send a message back to the main application window to restore it once the applications (App1 or App2) are closed.
private void App1_Click(object sender, System.EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
this.ShowInTaskbar = false;
Trash.Visible = true;
}
Can this scenario be handled without having to do anything with modifying the applications as such by a generic design pattern (Switch board)that acts more like a window manipulator?
Harihara Subramanian
|
|
|
|