Advertisement

03.21.2008 at 09:53PM PDT, ID: 23261111
[x]
Attachment Details

How to retrieve employee ID from Active Directory

Asked by OGSan in Active Server Pages (ASP)

Tags: Microsoft, ASP, ASP 3.0, IE 6

I have some code that I found on another post that validates an employee's user ID and password.
I know that a field called employeeID was added to our Active Directory.
What I need to do is to grab the value of the employeeID that is associated with the user ID/password combination that has just been validated.  Can someone please help me out?  Here is the code (apologies in advance for the mess).  Thank so much!Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>FMLA Validation</title>
</head>
<body>
<TABLE width="100%" cellpadding="0" cellspacing="0" border="0">
     <TR> 
          <TD width="70%">
<p class="heading1">
Please login: </p> 
 
<% 
on error resume next 
 
Dim strDomain 
Dim strADsPath 
Dim strUserName 
Dim strPassword 
Dim iFlags
Dim errorcount
 
errorcount = 0
 
' force the domain to ADHT
if   Request.Form("Domain") <> "ADHT" then
     strDomain = Request.Form("Domain")
     if strDomain = "" then strDomain = "ADHT" end if
else
     strDomain = "ADHT"
end if
 
strADsPath = strDomain 
iFlags = Request.Form("Flags") 
strPassword = Request.Form("Password") 
strUserName = Request.Form("UserName") 
 
%>
                
<form action = "Login.asp" method = "post" id=form1 name=form1>
                  <table width="46%" cellpadding="1">
                    <tr align="left" valign="middle"> 
                      <td width="15%"></td>
                      <td width="14%"><nobr>User name:&nbsp;</nobr></td>
                      <td width="71%"> <input type="text" id=UserName2 name=UserName size = 26 value=<%response.write strUserName%>> 
                      </td>
                    </tr>
                    <tr align="left" valign="middle"> 
                      <td>&nbsp; </td>
                      <td>Password:</td>
                      <td> <input type="password" id=Password2 name=Password size = 26 > 
                      </td>
                    </tr>
 
<input name=Domain type="hidden" id=Password3 value="<%response.write strDomain%>" size = 26 > 
                      </td>
                    </tr>
                    <tr valign="top"> 
                      <td colspan="3"> <div align="right"> 
                          <input type="hidden" id=Flags2 name=Flags size = 10 value = 0>
                          <input type="submit" value="   Login   " id=submit12 name=submit1>
                          <input type="reset" name="Reset" value="Reset">
                        </div></td>
                    </tr>
                  </table>
</form>
 
<% 
if (not strUserName= "") then 
 
      strADsPath = "WinNT://" & strADsPath 
      Dim oADsObject  
      Dim tempstr 
      tempstr = strDomain & "\" & strUserName 
 
      Set oADsObject = GetObject(strADsPath) 
 
      Dim strADsNamespace
      Dim strEmpID 
      Dim oADsNamespace 
      strADsNamespace = left(strADsPath, instr(strADsPath, ":")) 
      set oADsNamespace = GetObject(strADsNamespace) 
      Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, tempstr, strPassword, 0) 
    
           if not (Err.number = 0) then 
                                        
               Response.Write "Please provide a correct login name<br>or system password for the " & strDomain & " domain!<br>" 
                 'response.write err.description & "<p>" 
               if err.number = -2147022987 then ' for account logout
                    Response.write "<strong>Your account has been logged out!</strong>"
                end if
          
          else 
 
           Session("USER_LOGIN") = strUserName
           Session("isLoggedIn") = True
           Session("ValidUser") = True
'*** HOLD OFF          response.redirect "FMLAHours.asp" 
  %>
  <br>
  <% 
 Response.write "D E B U G&nbsp&nbsp&nbsp&nbsp&nbspS T A R T"
  %>
  <br>              
  <%
 oADsNamespace = GetObject(strADsNamespace) 
 strEmpID = oADsNamespace.employeeID
 Response.write "strempID: " & strempID
  %>
  <br>              
  <%
 Response.write "strADsNamespace: " & strADsNamespace 
  %>
  <br>              
  <%
 Response.write "strADsPath: " & strADsPath
  %>
  <br>              
  <%
 Response.write "tempstr: " & tempstr
  %>
  <br>              
  <%
 Response.write "D E B U G&nbsp&nbsp&nbsp&nbsp&nbspE N D"
  %>
  <br>              
  <%
          end if 
end if 
%>
          </TD>
        <TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
        <TD width="30%" valign="top"><font color="#999999">Please provide your COMPANY account login and password. <br>
     <br>Your account will be <strong>logged out</strong> after 3 unsuccessful logon attempts!
     <br>
     <br>
     </font></TD>
   </TR>
</TABLE>
</body>
</html>
[+][-]03.21.2008 at 10:00PM PDT, ID: 21184841

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.21.2008 at 10:03PM PDT, ID: 21184847

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.21.2008 at 10:32PM PDT, ID: 21184907

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.23.2008 at 09:09AM PDT, ID: 21189935

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.31.2008 at 12:07PM PDT, ID: 21248128

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.11.2008 at 08:49PM PDT, ID: 21339752

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.11.2008 at 08:50PM PDT, ID: 21339755

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.12.2008 at 02:08AM PDT, ID: 21340351

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Active Server Pages (ASP)
Tags: Microsoft, ASP, ASP 3.0, IE 6
Sign Up Now!
Solution Provided By: cedlinx
Participating Experts: 2
Solution Grade: C
 
 
[+][-]04.12.2008 at 02:17AM PDT, ID: 21340359

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.15.2008 at 05:28PM PDT, ID: 21363891

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.15.2008 at 08:20PM PDT, ID: 21364536

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628