none
sharepoint2010中如何获得域用户密码过期时间? RRS feed

  • 问题

  • 我想在sharepoint2010中获得某个域用户的密码过期时间, 也就是需要和ad交互,我不知道用户的密码,也许我可以在用户登录sharepoint时获取?

    或者使用moss的site admin账号去获取?

    2010年8月25日 15:10

答案

  • <script language="javascript" src="Shared%20Documents/SPAPI_Core.js"></script>
    <script language="javascript" src="Shared%20Documents/SPAPI_Lists.js"></script>
    <script language="javascript" src="Shared%20Documents/SPAPI_UserGroup.js"></script>

    <script language="JavaScript">

        function getCurrentUserName()   
        {   
            var curUserName = null;
            var lists = new SPAPI_Lists('')   
            var items = lists.getListItems(   
                'User Information List',   
                '',   
                '<Query><Where><Eq><FieldRef Name="ID"/><Value Type="Counter">' + _spUserId + '</Value></Eq></Where></Query>', // query   
                '<ViewFields><FieldRef Name="Name"/></ViewFields>',   
                1, // rowLimit   
                '' // queryOptions   
            );   
          
            if (items.status == 200)   
            {   
                var rows = items.responseXML.getElementsByTagName('z:row');   
          
                if (rows.length == 1)                  
                    curUserName = rows[0].getAttribute('ows_Name');                         
            }
               
            return curUserName;
        }  
        
        function getGroupCollection( userName )
        {
            var arrGroup = new Array();
            var userGroup = new SPAPI_UserGroup( '' )
            var groupItems = userGroup.getGroupCollectionFromUser( userName )
            
            if( groupItems.status == 200 )
            {
                var groupTags = groupItems.responseXML.getElementsByTagName( 'Group' );
                for( var i=0; i < groupTags.length; i++ )           
                    arrGroup.push( groupTags[i].getAttribute("Name") )          
            }
            return arrGroup;
        }
              
        // Test code   
        var userName = getCurrentUserName();
        var groups = getGroupCollection( userName )
        
        document.writeln( "UserName: " + userName + "<p />" )
        document.write( "Groups:" + groups );

    </script>

    代码下载:http://darrenjohnstone.net/

    2010年8月26日 4:02
    版主