Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Previewing in VFP app a User's AD Profile
Message
 
 
À
24/04/2006 14:48:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01116098
Message ID:
01116103
Vues:
23
>I want to know, if by using maybe a win32api code I can access or preview someone's profile in the Active Directory, Specifically I want to know the email of that user.
>
>What I really, Really would like to do is check a user's email like in "outlook" checkname feature... wich let's you type just a few letters of the user's name and "VOILA" the complete email appears in the text box for easy and fast sending. ANY HELP???

Ok, hopefully my colleague would not be upset for giving this code:
**************************************************************************************
*  Description.......: GetUserInformationBasedOnExchange
*  Calling Samples...:
*  Parameter List....: tcCursorName
*  Created by........: Ambrish Trivedi
*  Modified by.......:
**************************************************************************************
function GetUserInformationBasedOnExchange
lparameters tcCursorName
local rootDSE, DomainContainer, loConn, ;
	lcdapStr, rs, oUser, lcError

if empty(m.tcCursorName)
	tcCursorName = 'cUsers'
endif
lcError = ""
try
	create cursor (m.tcCursorName) ( cFullName C(100), cuserid C(100), ;
		cDepartment C(100), cPhone C(100))

	rootDSE = getobject("LDAP://RootDSE")
	DomainContainer = rootDSE.get("defaultNamingContext")
	loConn = createobject("ADODB.Connection")
	loConn.Provider = "ADSDSOObject"
	loConn.open("ADs Provider")
	lcdapStr = "<LDAP://" + DomainContainer + ;
		">;(& (mailnickname=*) (| (&(objectCategory=person)(objectClass=user)" + ;
		"(!(homeMDB=*))(!(msExchHomeServerName=*)))(&(objectCategory=person)" + ;
		"(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*))) ));adspath;subtree"
	rs = loConn.Execute(m.lcdapStr)

	do while  !rs.eof
		oUser = getobject(rs.fields(0).value)
		insert into (m.tcCursorName) (cFullName, cuserid, cDepartment, cPhone) ;
			values (upper(nvl(m.oUser.cn,"")), upper(nvl(m.oUser.sAMAccountName,"")), ;
			upper(nvl(m.oUser.department,"")), upper(nvl(m.oUser.telephoneNumber,"")))
		rs.MoveNext()
	enddo

catch to loError
	lcError = Log_Error(m.loError)
finally
	release rootDSE, DomainContainer, loConn, rs, oUser
endtry

return m.lcError
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform