[Mono-list] AuthenticationTypes.Secure problem
Wallmander Jonathan
jonathan.wallmander@consultant.volvo.com
Fri, 21 Jan 2005 11:33:10 +0100
Hello,
I'm trying to write a small script that verifies users against AD using =
mono.
Or rather, I'm porting one from windows.NET and want to run this in mono =
on linux.
Here's the code, based on examples here:
DirectoryEntry de =3D new =
DirectoryEntry("LDAP://server.domain.net/DC=3Dfoo,DC=3Dbar,DC=3Dbaz,DC=3D=
net"
,"myusername\myusername","mypass",AuthenticationTypes.Secure);
DirectorySearcher src =3D new =
DirectorySearcher("(objectclass=3DUser)");
//DataTable for users
DataTable tbUsers =3D new DataTable("users");
//Create Columns for DataTable.
tbUsers.Columns.Add("cn",System.Type.GetType("System.String"));
ds.Tables.Add(tbUsers);
//DataTable for properties
DataTable tbProperties =3D new DataTable("properties");
//Create Columns for DataTable.
=
tbProperties.Columns.Add("PropertyName",System.Type.GetType("System.Strin=
g"));
=
tbProperties.Columns.Add("PropertyValue",System.Type.GetType("System.Stri=
ng"));
ds.Tables.Add(tbProperties);
=09
src.SearchRoot =3D de;
src.SearchScope =3D SearchScope.Subtree;
src.Filter =3D ("(SAMAccountName=3Dmyusername)");
SearchResult res =3D null;
{
res =3D src.FindOne();
Console.WriteLine(res.ToString());
}
=09
/*catch (Exception ex) {
Console.WriteLine("Error authenticating user." + ex.Message);
}*/
=09
//foreach(SearchResult res in src.FindAll())
//{
//System.Collections.IDictionaryEnumerator ien =3D =
res.Properties.GetEnumerator();
if (res !=3D null) {
DataRow topRow =3D ds.Tables["users"].NewRow();
topRow["cn"] =3Dres.Properties["cn"][0];
ds.Tables["users"].Rows.Add(topRow);
DataGrid1.DataSource =3D ds.Tables["users"];
DataGrid1.DataBind();
}
---------
On the linux server (apache+mod_mono), i get this error:
Error Message: HTTP 500.
Stack Trace:
System.ArgumentNullException: Argument cannot be null.
in <0x00078> System.String:FormatHelper =
(System.Text.StringBuilder,System.IFormatProvider,string,object[])
in <0x0003d> System.String:Format =
(System.IFormatProvider,string,object[])
in <0x00175> Novell.Directory.Ldap.Utilclass.ResourcesHandler:getMessage =
(string,object[],System.Globalization.CultureInfo)
in <0x00013> Novell.Directory.Ldap.Utilclass.ResourcesHandler:getMessage =
(string,object[])
in <0x000bf> Novell.Directory.Ldap.LdapException:getExceptionString =
(string)
in <0x00013> Novell.Directory.Ldap.LdapException:ToString ()
in <0x0021f> System.Web.HttpException:GetDefaultErrorMessage ()
in <0x00047> System.Web.HttpException:GetHtmlErrorMessage ()
in <0x0021b> System.Web.HttpRuntime:FinishRequest =
(System.Web.HttpContext,System.Exception)
in <0x000fb> System.Web.HttpRuntime:OnHandlerReady (System.IAsyncResult)
in <0x0005d> (wrapper delegate-invoke) =
System.MulticastDelegate:invoke_void_IAsyncResult (System.IAsyncResult)
in <0x0003e> System.Web.HttpAsyncResult:Complete =
(bool,object,System.Exception)
in <0x00240> StateMachine:ExecuteNext (System.Exception)
in <0x00051> StateMachine:ExecuteNextAsync (System.Exception)
in <0x00022> StateMachine:Start ()
in <0x0006a> =
System.Web.HttpApplication:System.Web.IHttpAsyncHandler.BeginProcessReque=
st (System.Web.HttpContext,System.AsyncCallback,object)
in <0x002ee> System.Web.HttpRuntime:InternalExecuteRequest =
(System.Web.HttpWorkerRequest)
The examples
Does this mean that the .Secure type of the AuthenticationTypes enum =
isn't available? From what I can see,
AD uses kerberos+LDAP (but the manual of the .Secure in msdn says NTLM)
and hence should be possible to implement in mono on linux.. Or am I =
wrong?
Any explanation about this or help greatly appreciated :)
/jonathan wallmander