Exemple #1
0
        void DoLDAP(string S1)
        {
            this.Response.Clear();
            //this.Response.Output.Write(S);
            Hashtable   HH  = DataAccess.GetHashFromString(S1);
            string      E   = "Errore";
            QueryHelper QHS = Conn.GetQueryHelper();



            try {
                //Elabora la Hashtable per la mail
                string user = HH["usr"] as string;
                string pwd  = HH["pwd"] as string;
                string dep  = HH["dep"] as string;


                ldapauth LA = new ldapauth(Conn);
                if (!LA.getconfig())
                {
                    this.Response.Output.Write("Errore LA.getconfig: " + LA.ErrorMsg);
                    return;
                }
                if (!LA.Authenticate(user, pwd))
                {
                    this.Response.Output.Write("Errore LA.Authenticate: " + LA.ErrorMsg +
                                               "(servername=" + LA.servername + "port=" + LA.port.ToString() + "user="******",pwd=" + pwd + ")");
                    return;
                }
                user = LA.user_decoded;

                string filter = QHS.AppAnd(QHS.CmpEq("username", user),
                                           QHS.CmpEq("codicedipartimento", dep),
                                           QHS.CmpEq("userkind", 4)
                                           );
                // prelevare l'idflowchart e poi fare la connecttodepartment
                DataTable virtualuser = Conn.RUN_SELECT("virtualuser", "*", null, filter, null, false);
                if (virtualuser == null || virtualuser.Rows.Count == 0)
                {
                    this.Response.Output.Write("Errore: virtualuser not found (" + filter + ")");
                    Conn.Destroy();
                    return;
                }

                DataRow VU = virtualuser.Rows[0];



                string    filterdip = QHS.CmpEq("codicedipartimento", dep);
                DataTable CodDip    = Conn.RUN_SELECT("codicidipartimenti", "*", null, filterdip, null, true);
                if ((CodDip == null) || (CodDip.Rows.Count != 1))
                {
                    Conn.Destroy();
                    return;
                }
                Hashtable Hresp = new Hashtable();
                Hresp["usr"]  = GetVars.DecryptPassword(GetVars.ConvBytes(CodDip.Rows[0]["UserDB"]));
                Hresp["pwd"]  = GetVars.DecryptPassword(GetVars.ConvBytes(CodDip.Rows[0]["PassDB"]));
                Hresp["vusr"] = VU["sys_user"].ToString();
                E             = DataAccess.GetStringFromHashTable(Hresp);
            }
            catch (Exception EE) {
                E = "Errore:" + QueryCreator.GetErrorString(EE);
            }
            Conn.Destroy();
            this.Response.Output.Write(E.ToString());
        }