[JWF]Participant Interface访问ActiveDirectory

AdobeWorkFlow的Script可以很容易的访问系统内建的账户及用户属性,如果安装WF时与AD集成,需要编写代码来访问用户的其它属性。

但WF的Script与VBS脚本访问AD有一定的区别,不过基本方法都差不多。

在实际开发过程中,但用WF提供的访问去访问AD会比较简单。

在访问AD中用户属性时,要先查看一下下面的AD Schema的定义文件:
c:\Program Files\Adobe\Workflow Server\StringResources\ad-users.xm
这个文件定义了可以访问AD中用户的哪些属性。主要看一下//ColumnName节点的值。

使用方法如下:

    var userDisplayName = “xuzhong“
    var key = new Array();
    var value = new Array();
    key[0] = "DisplayName";
    value[0] = userDisplayName;
    var objUser = null;
    objUser = Directory.findFirstUser( key , value );
    var depart = objUser.attributes.item("Department");

执行上面的代码就可以得到xuzhong的部门属性

下面是我的一段例子:

currentUserObj = WorkItem.assignedTo;
Debug( "EVENT" , "Start process by " + currentUserObj.name );
Debug( "DEBUG" , "name=" + currentUserObj.name);
Debug( "DEBUG" , "className=" + currentUserObj.className );
Debug( "DEBUG" , "streetAddress=" + currentUserObj.attributes.item("streetAddress") );
Debug( "DEBUG" , "PostOfficeBox=" + currentUserObj.attributes.item("PostOfficeBox") );
Debug( "DEBUG" , "City=" + currentUserObj.attributes.item("City") );
Debug( "DEBUG" , "State=" + currentUserObj.attributes.item("State") );
Debug( "DEBUG" , "PostalCode=" + currentUserObj.attributes.item("PostalCode") );
Debug( "DEBUG" , "ADsPath=" + currentUserObj.attributes.item("ADsPath") );
Debug( "DEBUG" , "distinguishedName=" + currentUserObj.attributes.item("distinguishedName") );
Debug( "DEBUG" , "userPrincipalName=" + currentUserObj.attributes.item("userPrincipalName") );
Debug( "DEBUG" , "sAMAccountName=" + currentUserObj.attributes.item("sAMAccountName") );
Debug( "DEBUG" , "PhoneHome=" + currentUserObj.attributes.item("PhoneHome") );
Debug( "DEBUG" , "OtherPhoneHome=" + currentUserObj.attributes.item("OtherPhoneHome") );
Debug( "DEBUG" , "PhonePager=" + currentUserObj.attributes.item("PhonePager") );
Debug( "DEBUG" , "PhoneMobile=" + currentUserObj.attributes.item("PhoneMobile") );
Debug( "DEBUG" , "ipPhone=" + currentUserObj.attributes.item("ipPhone") );
Debug( "DEBUG" , "Info=" + currentUserObj.attributes.item("Info") );
Debug( "DEBUG" , "Title=" + currentUserObj.attributes.item("Title") );
Debug( "DEBUG" , "Department=" + currentUserObj.attributes.item("Department") );
Debug( "DEBUG" , "Company=" + currentUserObj.attributes.item("Company") );
Debug( "DEBUG" , "Manager=" + currentUserObj.attributes.item("Manager") );
Debug( "DEBUG" , "directReports=" + currentUserObj.attributes.item("directReports") );
Debug( "DEBUG" , "commonName=" + currentUserObj.attributes.item("commonName") );
Debug( "DEBUG" , "objectGUID=" + currentUserObj.attributes.item("objectGUID") );
Debug( "DEBUG" , "codePage=" + currentUserObj.attributes.item("codePage") );
Debug( "DEBUG" , "Linked=" + currentUserObj.attributes.item("Linked") );
Debug( "DEBUG" , "Registered=" + currentUserObj.attributes.item("Registered") );

输出结果:

[2005-7-13 16:28:43][DEBUG][name=徐中]
[2005-7-13 16:28:43][DEBUG][className=用户]
[2005-7-13 16:28:43][DEBUG][streetAddress=浑南新区新隆街6号]
[2005-7-13 16:28:43][DEBUG][PostOfficeBox=null]
[2005-7-13 16:28:43][DEBUG][City=沈阳]
[2005-7-13 16:28:43][DEBUG][State=辽宁省]
[2005-7-13 16:28:43][DEBUG][PostalCode=110079]
[2005-7-13 16:28:43][DEBUG][ADsPath=LDAP://CN=徐中,OU=系统维护室,****]
[2005-7-13 16:28:43][DEBUG][distinguishedName=CN=徐中,OU=系统维护室,****]
[2005-7-13 16:28:43][DEBUG][userPrincipalName=xuzhong@*****.***]
[2005-7-13 16:28:43][DEBUG][sAMAccountName=xuzhong]
[2005-7-13 16:28:43][DEBUG][PhoneHome=null]
[2005-7-13 16:28:43][DEBUG][OtherPhoneHome=null]
[2005-7-13 16:28:43][DEBUG][PhonePager=100001]
[2005-7-13 16:28:43][DEBUG][PhoneMobile=1389790****]
[2005-7-13 16:28:43][DEBUG][ipPhone=17951222222]
[2005-7-13 16:28:43][DEBUG][Info=1、参与各种日常开发
2、适应新的技术需求对网站、网页进行的开发性维护
3、学习各种开发相关的技术,掌握相关的技术技能。
4、参与网管相关的项目工作。
5、SQL SERVER数据库设计、变成。]
[2005-7-13 16:28:43][DEBUG][Title=程序员]
[2005-7-13 16:28:43][DEBUG][Department=系统室]
[2005-7-13 16:28:43][DEBUG][Company=*********]
[2005-7-13 16:28:43][DEBUG][Manager=CN=李亮,OU=系统维护室,****]
[2005-7-13 16:28:43][DEBUG][directReports=<multi><value>CN=王智,OU=科研所,****</value><value>CN=阎帅,OU=科研所,****</value><value>CN=武卓,OU=系统维护室,****</value></multi>]
[2005-7-13 16:28:43][DEBUG][commonName=徐中]
[2005-7-13 16:28:43][DEBUG][objectGUID=]
[2005-7-13 16:28:43][DEBUG][codePage=0]
[2005-7-13 16:28:43][DEBUG][Linked=1]
[2005-7-13 16:28:43][DEBUG][Registered=1]


文章来源:http://ms.mblogger.cn/xuzhong/posts/16671.aspx
原文地址:https://www.cnblogs.com/xuzhong/p/232227.html