Solo sirve para máquinas bajo Directorio Activo, no para PC's personales que no están en red y no están conectados a AD.
*----------------------------------------------- * DEVUELVE UN OBJETO CON INFORMACIÓN DEL USUARIO * (NOMBRES, APELLIDOS, ETC). FDBOZZO. 10/01/2017 *----------------------------------------------- * PARÁMETROS: (v=Pasar por valor | @=Pasar por referencia) * (!=Obligatorio | ?=Opcional) (IN/OUT) * tcInfo_IN (?v IN ) Valor a buscar (ej: 'NUUMA') * tcTipoInfo_IN (?v IN ) Tipo de valor a buscar (ej: 'mailNickName') * toInfoUsuario (!@ IN ) Variable donde devolver el objeto *---------------------------------------------------------------------------------- * * EJEMPLO DE USO: * * oInfoUsuario=NULL * DO user_info.prg WITH '','',oInfoUsuario * ? oInfoUsuario.fullname *---------------------------------------------------------------------------------- #DEFINE C_CR CHR(13) LPARAMETERS tcInfo_IN, tcTipoInfo_IN, toInfoUsuario LOCAL lcAlias, lcDomainNC, loRootDSE, lcQuery ; , loEx as Exception ; , loRS as ADODB.Recordset ; , loConnection as ADODB.Connection ; , loCommand as ADODB.Command TRY toInfoUsuario = .NULL. loRootDSE = .NULL. loUser = .NULL. lcAlias = '' lcQuery = '' loRS = .NULL. tcTipoInfo_IN = EVL(tcTipoInfo_IN, 'mailNickName') IF EMPTY(tcInfo_IN) lcAlias = ALLTRIM(SUBSTR(UPPER(SYS(0)), AT('#', SYS(0)) + 2)) ELSE lcAlias = ALLTRIM(tcInfo_IN) ENDIF *-- Windows 2000 Attribute (LDAP Name) *------------------------------------- * description * autoReply * businessRoles * co * company * delivContLength * department * displayName * displayNamePrintable * distinguishedName * dnQualifier * employeeID * extensionAttribute1 * extensionAttribute2 * extensionAttribute3 * extensionAttribute4 * extensionAttribute5 * extensionAttribute6 * extensionAttribute7 * extensionAttribute8 * extensionAttribute9 * extensionAttribute10 * extensionAttribute11 * extensionAttribute12 * extensionAttribute13 * extensionAttribute14 * extensionAttribute15 * facsimileTelephoneNumber * generationQualifier * homephone * homePostalAddress * houseIdentifier * info * initials * l * Language * mail * mailnickname * mobile * otherTelephone * otherHomePhone * telephoneAssistant * pager * personalPager * personalTitle * physicalDeliveryOfficeName * postalCode * secretary * sn * st * street * streetAddress * telephoneNumber * telexNumber * teletexTerminalIdentifier * textEncodedORAddress * title * userCertificate * userCert * userSMIMECertificate * url * x121Address * autoReplyMessage * importedFrom loConnection = CREATEOBJECT("ADODB.Connection") loCommand = CREATEOBJECT("ADODB.Command") loRootDSE = GETOBJECT("LDAP://RootDSE") lcDomainNC = loRootDSE.GET("defaultNamingContext") loConnection.Provider = "ADsDSOObject" loConnection.OPEN("ADs Provider") lcQuery = "<LDAP://" + lcDomainNC + ">;(" ; + tcTipoInfo_IN + "=" + lcAlias + ");adspath;subtree" loCommand.ActiveConnection = loConnection loCommand.CommandText = lcQuery loRS = loCommand.Execute IF loRS.RecordCount = 0 ERROR (TEXTMERGE('No se encontró información de "<<lcAlias>>"' ; + ' sobre el tipo de dato "<<tcTipoInfo_IN>>"')) ELSE toInfoUsuario = CREATEOBJECT("EMPTY") loAD_User = GETOBJECT(loRS.FIELDS("adspath").VALUE) ADDPROPERTY(toInfoUsuario, 'EmailAddress' ; , IIF(TYPE('loAD_User.EmailAddress') # 'U' ; , NVL(loAD_User.EmailAddress,''),'')) ADDPROPERTY(toInfoUsuario, 'FirstName' ; , IIF(TYPE('loAD_User.FirstName') # 'U' ; , NVL(loAD_User.FirstName,''),'')) ADDPROPERTY(toInfoUsuario, 'FullName' ; , IIF(TYPE('loAD_User.FullName') # 'U' ; , NVL(loAD_User.FULLNAME,''),'')) ADDPROPERTY(toInfoUsuario, 'LastName' ; , IIF(TYPE('loAD_User.LastName') # 'U' ; , NVL(loAD_User.LastName,''),'')) ENDIF CATCH TO loEx IF _VFP.StartMode=0 MESSAGEBOX( TEXTMERGE("ERROR <<loEx.ErrorNo>>" ; + ", <<loEx.Message>>" + C_CR ; + "Proc.<<loEx.Procedure>>" ; + ", Line <<loEx.LineNo>>") ) ENDIF THROW FINALLY IF VARTYPE(loConnection) = "O" AND loConnection.State = 1 loConnection.CLOSE() ENDIF STORE NULL TO loRS, loConnection, loCommand ENDTRY